test(radio): added some tests (#1022)

This commit is contained in:
Yanming Deng 2021-08-31 17:58:24 +08:00 committed by GitHub
parent 5e219eb8c6
commit 1ef0dc71b3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,6 +13,14 @@ describe('n-radio', () => {
expect(wrapper.find('.n-radio').classes()).toContain('n-radio--checked')
})
it('should work with `defaultChecked` prop', async () => {
let wrapper = mount(NRadio, { props: { defaultChecked: true } })
expect(wrapper.find('.n-radio').classes()).toContain('n-radio--checked')
wrapper = mount(NRadio, { props: { defaultChecked: false } })
expect(wrapper.find('.n-radio').classes()).not.toContain('n-radio--checked')
})
it('should work with `disabled` prop', async () => {
const wrapper = mount(NRadio, { props: { disabled: false } })
expect(wrapper.find('.n-radio').classes()).not.toContain(
@ -22,6 +30,18 @@ describe('n-radio', () => {
expect(wrapper.find('.n-radio').classes()).toContain('n-radio--disabled')
})
it('should work with `name` prop', async () => {
const wrapper = mount(NRadio, { props: { name: 'randomName111' } })
const radio = wrapper.find('input[type=radio')
expect(radio.attributes('name')).toEqual('randomName111')
await wrapper.setProps({ name: 'randomName222' })
expect(radio.attributes('name')).toEqual('randomName222')
})
it('should work with `size` prop', async () => {
const wrapper = mount(NRadio, { props: { size: 'small' } })
expect(wrapper.find('.n-radio').attributes('style')).toMatchSnapshot()