2020-08-04 11:45:50 +08:00
|
|
|
import { mount } from '@vue/test-utils'
|
2020-08-05 23:30:12 +08:00
|
|
|
import Radio from '../src/radio.vue'
|
2020-08-04 11:45:50 +08:00
|
|
|
|
2020-08-06 17:27:46 +08:00
|
|
|
const _mount = (template: string, data) => mount({
|
|
|
|
components: {
|
|
|
|
'el-radio': Radio,
|
|
|
|
},
|
|
|
|
template,
|
|
|
|
data,
|
|
|
|
}, {
|
|
|
|
global: {
|
|
|
|
provide: {
|
|
|
|
breadcrumb: {},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
2020-08-05 23:30:12 +08:00
|
|
|
describe('Radio', () => {
|
|
|
|
test('create', async () => {
|
2020-08-06 17:27:46 +08:00
|
|
|
const wrapper = _mount(`<el-radio v-model="radio" label="a">
|
|
|
|
</el-radio>`, () => ({ radio: '' }))
|
2020-08-05 23:30:12 +08:00
|
|
|
expect(wrapper.classes()).toContain('el-radio')
|
|
|
|
await wrapper.trigger('click')
|
|
|
|
expect(wrapper.classes()).toContain('is-checked')
|
2020-08-04 11:45:50 +08:00
|
|
|
})
|
2020-08-06 17:27:46 +08:00
|
|
|
|
|
|
|
test('disabled', async() => {
|
|
|
|
|
|
|
|
const wrapper = _mount(`<el-radio
|
|
|
|
v-model="radio"
|
|
|
|
label="3"
|
|
|
|
disabled
|
|
|
|
>
|
|
|
|
</el-radio>`, () => ({ radio: '' }))
|
|
|
|
await wrapper.trigger('click')
|
|
|
|
expect((wrapper.vm as any).radio).toBe('')
|
|
|
|
expect(wrapper.classes()).toContain('is-disabled')
|
|
|
|
})
|
|
|
|
|
|
|
|
it('border', () => {
|
|
|
|
const wrapper = _mount(`<el-radio
|
|
|
|
v-model="radio"
|
|
|
|
label="3"
|
|
|
|
border
|
|
|
|
>
|
|
|
|
</el-radio>`, () => ({ radio: '' }))
|
|
|
|
expect(wrapper.classes()).toContain('is-bordered')
|
|
|
|
})
|
2020-08-04 11:45:50 +08:00
|
|
|
})
|