-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathindex.test.js
37 lines (33 loc) · 1 KB
/
index.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import Switch from '..';
import { mount } from '@vue/test-utils';
import focusTest from '../../../tests/shared/focusTest';
import { resetWarned } from '../../_util/warning';
import mountTest from '../../../tests/shared/mountTest';
describe('Switch', () => {
focusTest(Switch);
mountTest(Switch);
it('should has click wave effect', async () => {
const wrapper = mount({
render() {
return <Switch />;
},
});
wrapper.find('.ant-switch').trigger('click');
await new Promise(resolve => setTimeout(resolve, 0));
expect(wrapper.html()).toMatchSnapshot();
});
it('warning if set `value`', () => {
resetWarned();
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
mount({
render() {
return <Switch value="" />;
},
});
console.log(errorSpy);
expect(errorSpy).toHaveBeenCalledWith(
'Warning: [antdv: Switch] `value` is not validate prop, do you mean `checked`?',
);
errorSpy.mockRestore();
});
});