You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

28 lines
1.0 KiB

import React from 'react';
import { mount } from 'enzyme';
import Switch from '..';
import Wave from '../../_util/wave';
import { sleep } from '../../../tests/utils';
describe('click wave effect', () => {
async function click(wrapper) {
wrapper.find('.ant-switch').getDOMNode().click();
wrapper.find('.ant-switch').getDOMNode().dispatchEvent(new Event('transitionstart'));
await sleep(20);
wrapper.find('.ant-switch').getDOMNode().dispatchEvent(new Event('animationend'));
await sleep(20);
}
it('should have click wave effect', async () => {
const wrapper = mount(<Switch />);
await click(wrapper);
const waveInstance = wrapper.find(Wave).instance();
const resetEffect = jest.spyOn(waveInstance, 'resetEffect');
await click(wrapper);
expect(resetEffect).toHaveBeenCalledTimes(1);
const event = new Event('animationend');
Object.assign(event, { animationName: 'fadeEffect' });
wrapper.find('.ant-switch').getDOMNode().dispatchEvent(event);
resetEffect.mockRestore();
});
});