mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-23 23:18:36 +08:00
502dac12aa
* docs: fix code * feat: lint * feat: prettier * feat: test * feat: review * feat: format html * feat: format html
32 lines
1.0 KiB
TypeScript
32 lines
1.0 KiB
TypeScript
import React from 'react';
|
|
|
|
import Switch from '..';
|
|
import { fireEvent, render, waitFakeTimer } from '../../../tests/utils';
|
|
|
|
describe('click wave effect', () => {
|
|
async function click(container: HTMLElement) {
|
|
fireEvent.click(container.querySelector('.ant-switch')!);
|
|
container.querySelector('.ant-switch')!.dispatchEvent(new Event('transitionstart'));
|
|
await waitFakeTimer();
|
|
container.querySelector('.ant-switch')!.dispatchEvent(new Event('animationend'));
|
|
await waitFakeTimer();
|
|
}
|
|
|
|
it('should have click wave effect', async () => {
|
|
jest.useFakeTimers();
|
|
const { container } = render(<Switch />);
|
|
await click(container);
|
|
await click(container);
|
|
|
|
expect(
|
|
container.querySelector('.ant-switch')!.getAttribute('ant-switch-click-animating'),
|
|
).toBeFalsy();
|
|
|
|
const event = new Event('animationend');
|
|
Object.assign(event, { animationName: 'fadeEffect' });
|
|
container.querySelector('.ant-switch')!.dispatchEvent(event);
|
|
jest.clearAllTimers();
|
|
jest.useRealTimers();
|
|
});
|
|
});
|