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-01-12 03:33:27 +00:00
|
|
|
wrapper.trigger('mouseenter');
|
|
|
|
});
|
2018-06-17 09:25:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(onMouseEnter).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
wrapper.trigger('mouseleave');
|
2018-06-17 09:25:54 +00:00
|
|
|
await asyncExpect(() => {
|
2019-01-12 03:33:27 +00:00
|
|
|
expect(onMouseLeave).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|