2019-01-12 03:33:27 +00:00
|
|
|
import { mount } from '@vue/test-utils';
|
|
|
|
import { asyncExpect } from '@/tests/utils';
|
2020-03-07 11:45:13 +00:00
|
|
|
import Radio, { Group, Button } from '..';
|
2019-01-12 03:33:27 +00:00
|
|
|
import focusTest from '../../../tests/shared/focusTest';
|
2020-03-07 11:45:13 +00:00
|
|
|
import mountTest from '../../../tests/shared/mountTest';
|
2018-06-17 09:25:54 +00:00
|
|
|
|
|
|
|
describe('Radio', () => {
|
2019-01-12 03:33:27 +00:00
|
|
|
focusTest(Radio);
|
2020-03-07 11:45:13 +00:00
|
|
|
mountTest(Radio);
|
|
|
|
mountTest(Group);
|
|
|
|
mountTest(Button);
|
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();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|