2020-08-09 14:10:57 +08:00
|
|
|
import { nextTick } from 'vue'
|
2021-08-24 13:36:48 +08:00
|
|
|
import { mount } from '@vue/test-utils'
|
2022-04-19 12:46:57 +08:00
|
|
|
import { describe, expect, it, test } from 'vitest'
|
2022-05-05 22:04:32 +08:00
|
|
|
import { ElFormItem } from '@element-plus/components/form'
|
2020-08-05 23:30:12 +08:00
|
|
|
import Radio from '../src/radio.vue'
|
2020-08-07 16:44:59 +08:00
|
|
|
import RadioGroup from '../src/radio-group.vue'
|
|
|
|
import RadioButton from '../src/radio-button.vue'
|
2020-08-04 11:45:50 +08:00
|
|
|
|
2021-09-04 19:29:28 +08:00
|
|
|
const _mount = (template: string, data, otherObj?) =>
|
|
|
|
mount({
|
|
|
|
components: {
|
|
|
|
'el-radio': Radio,
|
|
|
|
'el-radio-group': RadioGroup,
|
|
|
|
'el-radio-button': RadioButton,
|
2022-05-05 22:04:32 +08:00
|
|
|
'el-form-item': ElFormItem,
|
2021-09-04 19:29:28 +08:00
|
|
|
},
|
|
|
|
template,
|
|
|
|
data,
|
|
|
|
...otherObj,
|
|
|
|
})
|
2020-08-06 17:27:46 +08:00
|
|
|
|
2020-08-05 23:30:12 +08:00
|
|
|
describe('Radio', () => {
|
|
|
|
test('create', async () => {
|
2021-09-04 19:29:28 +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
|
|
|
|
2020-08-07 16:44:59 +08:00
|
|
|
test('disabled', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio
|
2020-08-06 17:27:46 +08:00
|
|
|
v-model="radio"
|
|
|
|
label="3"
|
|
|
|
disabled
|
|
|
|
>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio>`,
|
|
|
|
() => ({ radio: '' })
|
|
|
|
)
|
2020-08-06 17:27:46 +08:00
|
|
|
await wrapper.trigger('click')
|
2020-08-07 16:44:59 +08:00
|
|
|
const vm = wrapper.vm as any
|
|
|
|
expect(vm.radio).toBe('')
|
2020-08-06 17:27:46 +08:00
|
|
|
expect(wrapper.classes()).toContain('is-disabled')
|
|
|
|
})
|
|
|
|
|
2020-08-07 16:44:59 +08:00
|
|
|
test('border', () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio
|
2020-08-06 17:27:46 +08:00
|
|
|
v-model="radio"
|
|
|
|
label="3"
|
|
|
|
border
|
|
|
|
>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio>`,
|
|
|
|
() => ({ radio: '' })
|
|
|
|
)
|
2020-08-06 17:27:46 +08:00
|
|
|
expect(wrapper.classes()).toContain('is-bordered')
|
|
|
|
})
|
2020-08-07 16:44:59 +08:00
|
|
|
|
2022-05-17 12:28:20 +08:00
|
|
|
test('change event', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio
|
2020-08-07 16:44:59 +08:00
|
|
|
v-model="radio"
|
|
|
|
label="3"
|
|
|
|
@change="handleChange"
|
|
|
|
>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio>`,
|
|
|
|
() => ({
|
|
|
|
radio: '',
|
|
|
|
changeData: '',
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
methods: {
|
|
|
|
handleChange(val) {
|
|
|
|
this.changeData = val
|
|
|
|
},
|
2020-08-07 16:44:59 +08:00
|
|
|
},
|
2021-09-04 19:29:28 +08:00
|
|
|
}
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
const vm = wrapper.vm as any
|
|
|
|
await wrapper.trigger('click')
|
2020-08-19 20:41:06 +08:00
|
|
|
await nextTick()
|
2020-08-07 16:44:59 +08:00
|
|
|
expect(vm.changeData).toEqual('3')
|
|
|
|
})
|
|
|
|
|
|
|
|
test('change event only triggers on user input', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio
|
2020-08-07 16:44:59 +08:00
|
|
|
v-model="radio"
|
|
|
|
label="3"
|
|
|
|
@change="handleChange"
|
|
|
|
>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio>`,
|
|
|
|
() => ({
|
|
|
|
radio: '',
|
|
|
|
changeData: '',
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
methods: {
|
|
|
|
handleChange(val) {
|
|
|
|
this.changeData = val
|
|
|
|
},
|
2020-08-07 16:44:59 +08:00
|
|
|
},
|
2021-09-04 19:29:28 +08:00
|
|
|
}
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
const vm = wrapper.vm as any
|
|
|
|
vm.radio = '3'
|
2020-08-09 14:10:57 +08:00
|
|
|
await nextTick()
|
2020-08-07 16:44:59 +08:00
|
|
|
expect(vm.changeData).toEqual('')
|
|
|
|
expect(vm.radio).toEqual('3')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Radio group', () => {
|
|
|
|
it('create', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio-group v-model="radio">
|
2020-08-07 16:44:59 +08:00
|
|
|
<el-radio :label="3" ref="radio1">3</el-radio>
|
|
|
|
<el-radio :label="6" ref="radio2">6</el-radio>
|
|
|
|
<el-radio :label="9">9</el-radio>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
radio: 3,
|
|
|
|
})
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
const radio1 = wrapper.findComponent({ ref: 'radio1' })
|
|
|
|
expect(radio1.classes()).toContain('is-checked')
|
|
|
|
const radio2 = wrapper.findComponent({ ref: 'radio2' })
|
|
|
|
await radio2.trigger('click')
|
|
|
|
expect(radio2.classes()).toContain('is-checked')
|
|
|
|
const vm = wrapper.vm as any
|
|
|
|
expect(vm.radio).toEqual(6)
|
|
|
|
})
|
|
|
|
|
2022-05-23 18:27:27 +08:00
|
|
|
it('id auto derive', async () => {
|
|
|
|
const wrapper1 = _mount(
|
|
|
|
`<el-radio-group v-model="radio">
|
|
|
|
<el-radio :label="3" ref="radio1">3</el-radio>
|
|
|
|
<el-radio :label="6" ref="radio2">6</el-radio>
|
|
|
|
<el-radio :label="9">9</el-radio>
|
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
radio: 3,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
const wrapper2 = _mount(
|
|
|
|
`<el-radio-group v-model="radio">
|
|
|
|
<el-radio :label="3" ref="radio1">3</el-radio>
|
|
|
|
<el-radio :label="6" ref="radio2">6</el-radio>
|
|
|
|
<el-radio :label="9">9</el-radio>
|
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
radio: 3,
|
|
|
|
})
|
|
|
|
)
|
|
|
|
|
|
|
|
const id1 = wrapper1
|
|
|
|
.findComponent({ name: 'ElRadio' })
|
|
|
|
.find('input')
|
|
|
|
.attributes('name')
|
|
|
|
|
|
|
|
const id2 = wrapper2
|
|
|
|
.findComponent({ name: 'ElRadio' })
|
|
|
|
.find('input')
|
|
|
|
.attributes('name')
|
|
|
|
|
|
|
|
expect(id1).not.toEqual(id2)
|
|
|
|
})
|
|
|
|
|
2020-08-07 16:44:59 +08:00
|
|
|
it('disabled', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio-group v-model="radio" disabled>
|
2020-08-07 16:44:59 +08:00
|
|
|
<el-radio :label="3" ref="radio1">3</el-radio>
|
|
|
|
<el-radio :label="6" ref="radio2">6</el-radio>
|
|
|
|
<el-radio :label="9">7</el-radio>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
radio: 3,
|
|
|
|
})
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
|
|
|
|
expect(wrapper.find('label.is-disabled').exists()).toBe(true)
|
|
|
|
const radio1 = wrapper.findComponent({ ref: 'radio1' })
|
|
|
|
expect(radio1.classes()).toContain('is-checked')
|
|
|
|
const radio2 = wrapper.findComponent({ ref: 'radio2' })
|
|
|
|
await radio2.trigger('click')
|
|
|
|
const vm = wrapper.vm as any
|
|
|
|
expect(vm.radio).toEqual(3)
|
|
|
|
expect(radio1.classes()).toContain('is-checked')
|
|
|
|
})
|
|
|
|
it('change event', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio-group v-model="radio" @change="onChange">
|
2020-08-07 16:44:59 +08:00
|
|
|
<el-radio :label="3">3</el-radio>
|
|
|
|
<el-radio :label="6" ref="radio2">6</el-radio>
|
|
|
|
<el-radio :label="9">9</el-radio>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
radio: 3,
|
|
|
|
data: 0,
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
methods: {
|
|
|
|
onChange(val) {
|
|
|
|
this.data = val
|
|
|
|
},
|
2020-08-07 16:44:59 +08:00
|
|
|
},
|
2021-09-04 19:29:28 +08:00
|
|
|
}
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
|
|
|
|
const radio2 = wrapper.findComponent({ ref: 'radio2' })
|
|
|
|
await radio2.trigger('click')
|
2020-08-19 20:41:06 +08:00
|
|
|
await nextTick()
|
2020-08-07 16:44:59 +08:00
|
|
|
const vm = wrapper.vm as any
|
|
|
|
expect(vm.data).toEqual(6)
|
|
|
|
})
|
|
|
|
it('change event only triggers on user input', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio-group v-model="radio" @change="onChange">
|
2020-08-07 16:44:59 +08:00
|
|
|
<el-radio :label="3">3</el-radio>
|
|
|
|
<el-radio :label="6" ref="radio2">6</el-radio>
|
|
|
|
<el-radio :label="9">9</el-radio>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
radio: 3,
|
|
|
|
data: 0,
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
methods: {
|
|
|
|
onChange(val) {
|
|
|
|
this.data = val
|
|
|
|
},
|
2020-08-07 16:44:59 +08:00
|
|
|
},
|
2021-09-04 19:29:28 +08:00
|
|
|
}
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
const vm = wrapper.vm as any
|
|
|
|
vm.radio = 6
|
2020-08-09 14:10:57 +08:00
|
|
|
await nextTick()
|
2020-08-07 16:44:59 +08:00
|
|
|
expect(vm.data).toEqual(0)
|
|
|
|
})
|
|
|
|
it('disabled when children is radio button', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio-group v-model="radio" disabled>
|
2020-08-07 16:44:59 +08:00
|
|
|
<el-radio-button :label="3" ref="radio1">3</el-radio-button>
|
|
|
|
<el-radio-button :label="6" ref="radio2">6</el-radio-button>
|
|
|
|
<el-radio-button :label="9">9</el-radio-button>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
radio: 3,
|
|
|
|
})
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
|
|
|
|
const radio1 = wrapper.findComponent({ ref: 'radio1' })
|
|
|
|
const radio2 = wrapper.findComponent({ ref: 'radio2' })
|
|
|
|
expect(radio1.classes()).toContain('is-active')
|
|
|
|
expect(wrapper.findAll('.is-disabled').length).toBe(3)
|
|
|
|
await radio2.trigger('click')
|
|
|
|
const vm = wrapper.vm as any
|
|
|
|
expect(vm.radio).toEqual(3)
|
|
|
|
expect(radio1.classes()).toContain('is-active')
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('Radio Button', () => {
|
|
|
|
it('create', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio-group v-model="radio">
|
2020-08-07 16:44:59 +08:00
|
|
|
<el-radio-button :label="3" ref="radio1">3</el-radio-button>
|
|
|
|
<el-radio-button :label="6" ref="radio2">6</el-radio-button>
|
|
|
|
<el-radio-button :label="9">9</el-radio-button>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
radio: 3,
|
|
|
|
})
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
const radio1 = wrapper.findComponent({ ref: 'radio1' })
|
|
|
|
expect(radio1.classes()).toContain('is-active')
|
|
|
|
const radio2 = wrapper.findComponent({ ref: 'radio2' })
|
|
|
|
await radio2.trigger('click')
|
|
|
|
expect(radio2.classes()).toContain('is-active')
|
|
|
|
const vm = wrapper.vm as any
|
|
|
|
expect(vm.radio).toEqual(6)
|
|
|
|
})
|
|
|
|
it('custom color', () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio-group v-model="radio" fill="#000" text-color="#ff0">
|
2020-08-07 16:44:59 +08:00
|
|
|
<el-radio-button :label="3" ref="radio1">3</el-radio-button>
|
|
|
|
<el-radio-button :label="6" ref="radio2">6</el-radio-button>
|
|
|
|
<el-radio-button :label="9">9</el-radio-button>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
radio: 3,
|
|
|
|
})
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
const radio1 = wrapper.findComponent({ ref: 'radio1' })
|
2021-09-04 19:29:28 +08:00
|
|
|
expect(radio1.find('span').attributes('style')).toContain(
|
|
|
|
'background-color: rgb(0, 0, 0); border-color: #000; box-shadow: -1px 0 0 0 #000; color: rgb(255, 255, 0);'
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
})
|
|
|
|
it('change event', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio-group v-model="radio" @change="onChange">
|
2020-08-07 16:44:59 +08:00
|
|
|
<el-radio-button :label="3">3</el-radio-button>
|
|
|
|
<el-radio-button :label="6" ref="radio2">6</el-radio-button>
|
|
|
|
<el-radio-button :label="9">9</el-radio-button>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
data: 0,
|
|
|
|
radio: 3,
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
methods: {
|
|
|
|
onChange(val) {
|
|
|
|
this.data = val
|
|
|
|
},
|
2020-08-07 16:44:59 +08:00
|
|
|
},
|
2021-09-04 19:29:28 +08:00
|
|
|
}
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
const radio2 = wrapper.findComponent({ ref: 'radio2' })
|
|
|
|
await radio2.trigger('click')
|
|
|
|
const vm = wrapper.vm as any
|
|
|
|
expect(vm.radio).toEqual(6)
|
|
|
|
})
|
|
|
|
it('change event only triggers on user input', async () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio-group v-model="radio" @change="onChange">
|
2020-08-07 16:44:59 +08:00
|
|
|
<el-radio-button :label="3">3</el-radio-button>
|
|
|
|
<el-radio-button :label="6" ref="radio2">6</el-radio-button>
|
|
|
|
<el-radio-button :label="9">9</el-radio-button>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
data: 0,
|
|
|
|
radio: 3,
|
|
|
|
}),
|
|
|
|
{
|
|
|
|
methods: {
|
|
|
|
onChange(val) {
|
|
|
|
this.data = val
|
|
|
|
},
|
2020-08-07 16:44:59 +08:00
|
|
|
},
|
2021-09-04 19:29:28 +08:00
|
|
|
}
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
const vm = wrapper.vm as any
|
|
|
|
vm.radio = 6
|
2020-08-09 14:10:57 +08:00
|
|
|
await nextTick()
|
2020-08-07 16:44:59 +08:00
|
|
|
expect(vm.data).toEqual(0)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('size', () => {
|
2021-09-04 19:29:28 +08:00
|
|
|
const wrapper = _mount(
|
|
|
|
`<el-radio-group v-model="radio" size="large">
|
2020-08-07 16:44:59 +08:00
|
|
|
<el-radio-button :label="3" ref="radio1">3</el-radio-button>
|
|
|
|
<el-radio-button :label="6" ref="radio2">6</el-radio-button>
|
|
|
|
<el-radio-button :label="9">9</el-radio-button>
|
2021-09-04 19:29:28 +08:00
|
|
|
</el-radio-group>`,
|
|
|
|
() => ({
|
|
|
|
radio: 3,
|
|
|
|
})
|
|
|
|
)
|
2020-08-07 16:44:59 +08:00
|
|
|
expect(wrapper.findAll('.el-radio-button--large').length).toBe(3)
|
|
|
|
})
|
2022-05-05 22:04:32 +08:00
|
|
|
|
|
|
|
describe('form item accessibility integration', () => {
|
|
|
|
test('single radio group in form item', async () => {
|
|
|
|
const wrapper = _mount(
|
|
|
|
`
|
|
|
|
<el-form-item ref="item" label="Test">
|
|
|
|
<el-radio-group ref="radioGroup">
|
|
|
|
<el-radio label="Foo" />
|
|
|
|
<el-radio label="Bar" />
|
|
|
|
</el-radio-group>
|
|
|
|
</el-form-item>
|
|
|
|
`,
|
|
|
|
() => ({})
|
|
|
|
)
|
|
|
|
await nextTick()
|
|
|
|
const formItem = await wrapper.findComponent({ ref: 'item' })
|
|
|
|
const radioGroup = await wrapper.findComponent({
|
|
|
|
ref: 'radioGroup',
|
|
|
|
})
|
|
|
|
const formItemLabel = formItem.find('.el-form-item__label')
|
|
|
|
expect(formItem.attributes().role).toBeFalsy()
|
|
|
|
expect(radioGroup.attributes().role).toBe('radiogroup')
|
|
|
|
expect(formItemLabel.attributes().for).toBe(radioGroup.attributes().id)
|
|
|
|
expect(formItemLabel.attributes().id).toBe(
|
|
|
|
radioGroup.attributes()['aria-labelledby']
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
|
|
|
test('single radio group in form item, override label', async () => {
|
|
|
|
const wrapper = _mount(
|
|
|
|
`
|
|
|
|
<el-form-item ref="item" label="Test">
|
|
|
|
<el-radio-group label="Foo" ref="radioGroup">
|
|
|
|
<el-radio label="Foo" />
|
|
|
|
<el-radio label="Bar" />
|
|
|
|
</el-radio-group>
|
|
|
|
</el-form-item>
|
|
|
|
`,
|
|
|
|
() => ({})
|
|
|
|
)
|
|
|
|
await nextTick()
|
|
|
|
const formItem = await wrapper.findComponent({ ref: 'item' })
|
|
|
|
const radioGroup = await wrapper.findComponent({
|
|
|
|
ref: 'radioGroup',
|
|
|
|
})
|
|
|
|
const formItemLabel = formItem.find('.el-form-item__label')
|
|
|
|
expect(formItemLabel.attributes().for).toBe(radioGroup.attributes().id)
|
|
|
|
expect(radioGroup.attributes().role).toBe('radiogroup')
|
|
|
|
expect(radioGroup.attributes()['aria-label']).toBe('Foo')
|
|
|
|
expect(radioGroup.attributes()['aria-labelledby']).toBeFalsy()
|
|
|
|
})
|
|
|
|
|
|
|
|
test('multiple radio groups in form item', async () => {
|
|
|
|
const wrapper = _mount(
|
|
|
|
`
|
|
|
|
<el-form-item ref="item" label="Test">
|
|
|
|
<el-radio-group label="Foo" ref="radioGroup1">
|
|
|
|
<el-radio label="Foo" />
|
|
|
|
<el-radio label="Bar" />
|
|
|
|
</el-radio-group>
|
|
|
|
<el-radio-group label="Bar" ref="radioGroup2">
|
|
|
|
<el-radio label="Foo" />
|
|
|
|
<el-radio label="Bar" />
|
|
|
|
</el-radio-group>
|
|
|
|
</el-form-item>
|
|
|
|
`,
|
|
|
|
() => ({})
|
|
|
|
)
|
|
|
|
await nextTick()
|
|
|
|
const formItem = await wrapper.findComponent({ ref: 'item' })
|
|
|
|
const radioGroup1 = await wrapper.findComponent({
|
|
|
|
ref: 'radioGroup1',
|
|
|
|
})
|
|
|
|
const radioGroup2 = await wrapper.findComponent({
|
|
|
|
ref: 'radioGroup2',
|
|
|
|
})
|
|
|
|
const formItemLabel = formItem.find('.el-form-item__label')
|
|
|
|
expect(formItem.attributes().role).toBe('group')
|
|
|
|
expect(formItem.attributes()['aria-labelledby']).toBe(
|
|
|
|
formItemLabel.attributes().id
|
|
|
|
)
|
|
|
|
expect(radioGroup1.attributes().role).toBe('radiogroup')
|
|
|
|
expect(radioGroup1.attributes()['aria-label']).toBe('Foo')
|
|
|
|
expect(radioGroup1.attributes()['aria-labelledby']).toBeFalsy()
|
|
|
|
expect(radioGroup2.attributes().role).toBe('radiogroup')
|
|
|
|
expect(radioGroup2.attributes()['aria-label']).toBe('Bar')
|
|
|
|
expect(radioGroup2.attributes()['aria-labelledby']).toBeFalsy()
|
|
|
|
})
|
|
|
|
})
|
2020-08-04 11:45:50 +08:00
|
|
|
})
|