mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-24 11:05:17 +08:00
fix: [el-checkbox-group]: default value adjusted to empty array (#4316)
fix #4300
This commit is contained in:
parent
8f57bf610e
commit
1d0d0053fc
@ -106,7 +106,7 @@ checkbox/with-border
|
||||
|
||||
| Attribute | Description | Type | Accepted Values | Default |
|
||||
| --------------------- | ------------------------------------------------- | ------- | ---------------------- | ------- |
|
||||
| model-value / v-model | binding value | array | — | — |
|
||||
| model-value / v-model | binding value | array | — | [] |
|
||||
| size | size of checkbox | string | large / default /small | — |
|
||||
| disabled | whether the nesting checkboxes are disabled | boolean | — | false |
|
||||
| min | minimum number of checkbox checked | number | — | — |
|
||||
|
@ -95,6 +95,24 @@ describe('Checkbox', () => {
|
||||
expect(vm.checkList).toContain('b')
|
||||
})
|
||||
|
||||
test('checkbox group without modelValue', async () => {
|
||||
const wrapper = _mount(
|
||||
`
|
||||
<el-checkbox-group v-model="checkList">
|
||||
<el-checkbox label="a" ref="a"></el-checkbox>
|
||||
<el-checkbox label="b" ref="b"></el-checkbox>
|
||||
<el-checkbox label="c" ref="c"></el-checkbox>
|
||||
<el-checkbox label="d" ref="d"></el-checkbox>
|
||||
</el-checkbox-group>
|
||||
`,
|
||||
() => ({ checkList: undefined })
|
||||
)
|
||||
const vm = wrapper.vm
|
||||
await wrapper.findComponent({ ref: 'a' }).trigger('click')
|
||||
expect(vm.checkList.length).toBe(1)
|
||||
expect(vm.checkList).toContain('a')
|
||||
})
|
||||
|
||||
test('checkbox group change', async () => {
|
||||
const wrapper = _mount(
|
||||
`
|
||||
|
@ -26,8 +26,8 @@ export default defineComponent({
|
||||
|
||||
props: {
|
||||
modelValue: {
|
||||
type: [Object, Boolean, Array],
|
||||
default: () => undefined,
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
disabled: Boolean,
|
||||
min: {
|
||||
|
Loading…
Reference in New Issue
Block a user