ant-design/components/switch/__tests__/index.test.js

31 lines
862 B
JavaScript
Raw Normal View History

import React from 'react';
import { mount } from 'enzyme';
2019-06-25 12:08:32 +08:00
import Switch from '..';
import focusTest from '../../../tests/shared/focusTest';
import { resetWarned } from '../../_util/warning';
describe('Switch', () => {
focusTest(Switch);
it('should has click wave effect', async () => {
const wrapper = mount(<Switch />);
2018-12-07 16:17:45 +08:00
wrapper
.find('.ant-switch')
.getDOMNode()
.click();
await new Promise(resolve => setTimeout(resolve, 0));
expect(wrapper.render()).toMatchSnapshot();
});
it('warning if set `value`', () => {
resetWarned();
const errorSpy = jest.spyOn(console, 'error').mockImplementation(() => {});
mount(<Switch value />);
expect(errorSpy).toHaveBeenCalledWith(
'Warning: [antd: Switch] `value` is not validate prop, do you mean `checked`?',
);
errorSpy.mockRestore();
});
});