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

42 lines
1008 B
JavaScript
Raw Normal View History

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