ant-design/components/config-provider/__tests__/wave.test.tsx
二货爱吃白萝卜 8b19102b0d
feat: wave effect config (#43784)
* feat: support wave effect

* docs: more info

* test: add test case

* docs: update demo

* test: coverage
2023-07-25 16:29:47 +08:00

51 lines
1.2 KiB
TypeScript

import React from 'react';
import ConfigProvider from '..';
import { fireEvent, render, waitFakeTimer } from '../../../tests/utils';
import Button from '../../button';
jest.mock('rc-util/lib/Dom/isVisible', () => () => true);
describe('ConfigProvider.Wave', () => {
beforeEach(() => {
jest.useFakeTimers();
});
afterEach(() => {
jest.useRealTimers();
});
it('disable', async () => {
const showEffect = jest.fn();
const onClick = jest.fn();
const { container } = render(
<ConfigProvider wave={{ disabled: true, showEffect }}>
<Button onClick={onClick} />
</ConfigProvider>,
);
fireEvent.click(container.querySelector('button')!);
await waitFakeTimer();
expect(onClick).toHaveBeenCalled();
expect(showEffect).not.toHaveBeenCalled();
});
it('support customize effect', async () => {
const showEffect = jest.fn();
const onClick = jest.fn();
const { container } = render(
<ConfigProvider wave={{ showEffect }}>
<Button onClick={onClick} />
</ConfigProvider>,
);
fireEvent.click(container.querySelector('button')!);
await waitFakeTimer();
expect(onClick).toHaveBeenCalled();
expect(showEffect).toHaveBeenCalled();
});
});