ant-design-vue/components/radio/__tests__/radio.test.js

42 lines
1.0 KiB
JavaScript
Raw Normal View History

2019-01-12 03:33:27 +00:00
import { mount } from '@vue/test-utils';
import { asyncExpect } from '@/tests/utils';
import Radio from '../Radio';
import focusTest from '../../../tests/shared/focusTest';
2018-06-17 09:25:54 +00:00
describe('Radio', () => {
2019-01-12 03:33:27 +00:00
focusTest(Radio);
2018-06-17 09:25:54 +00:00
it('should render correctly', () => {
const wrapper = mount({
2019-01-12 03:33:27 +00:00
render() {
return <Radio class="customized">Test</Radio>;
2018-06-17 09:25:54 +00:00
},
2019-01-12 03:33:27 +00:00
});
expect(wrapper.html()).toMatchSnapshot();
});
2018-06-17 09:25:54 +00:00
it('responses hover events', async () => {
2019-01-12 03:33:27 +00:00
const onMouseEnter = jest.fn();
const onMouseLeave = jest.fn();
2018-06-17 09:25:54 +00:00
2019-01-12 03:33:27 +00:00
const wrapper = mount(
{
render() {
return <Radio onMouseenter={onMouseEnter} onMouseleave={onMouseLeave} />;
},
2018-06-17 09:25:54 +00:00
},
2019-01-12 03:33:27 +00:00
{ sync: false },
);
2018-06-17 09:25:54 +00:00
await asyncExpect(() => {
2019-09-18 12:03:13 +00:00
wrapper.find('label').trigger('mouseenter');
2019-01-12 03:33:27 +00:00
});
2018-06-17 09:25:54 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(onMouseEnter).toHaveBeenCalled();
});
2019-09-18 12:03:13 +00:00
wrapper.find('label').trigger('mouseleave');
2018-06-17 09:25:54 +00:00
await asyncExpect(() => {
2019-01-12 03:33:27 +00:00
expect(onMouseLeave).toHaveBeenCalled();
});
});
});