mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-03 00:09:39 +08:00
502dac12aa
* docs: fix code * feat: lint * feat: prettier * feat: test * feat: review * feat: format html * feat: format html
52 lines
1.2 KiB
TypeScript
52 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();
|
|
});
|
|
});
|