Skip to content

Commit 9fc649d

Browse files
committed
fix tests: modelValues, checkbox and radio
1 parent 05990e6 commit 9fc649d

File tree

8 files changed

+228
-377
lines changed

8 files changed

+228
-377
lines changed

src/components/BFormCheckbox/form-checkbox-group.spec.js

Lines changed: 10 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,10 @@ describe('form-checkbox-group', () => {
347347
attachTo: createContainer(),
348348
global,
349349
props: {
350-
'options': ['one', 'two', 'three'],
351-
'modelValue': [],
350+
options: ['one', 'two', 'three'],
351+
modelValue: [],
352+
},
353+
attrs: {
352354
'onUpdate:modelValue': (modelValue) => wrapper.setProps({modelValue}),
353355
},
354356
})
@@ -392,55 +394,6 @@ describe('form-checkbox-group', () => {
392394
wrapper.unmount()
393395
})
394396

395-
it('does not emit "input" event when value loosely changes', async () => {
396-
const value = ['one', 'two', 'three']
397-
const wrapper = mount(BFormCheckboxGroup, {
398-
attachTo: createContainer(),
399-
global,
400-
props: {
401-
'options': value.slice(),
402-
'modelValue': value.slice(),
403-
'onUpdate:modelValue': (modelValue) => wrapper.setProps({modelValue}),
404-
},
405-
})
406-
407-
expect(wrapper.classes()).toBeDefined()
408-
409-
const $inputs = wrapper.findAll('input[type=checkbox]')
410-
expect($inputs.length).toBe(3)
411-
expect(wrapper.vm.modelValue).toEqual(value)
412-
expect($inputs[0].element.checked).toBe(true)
413-
expect($inputs[1].element.checked).toBe(true)
414-
expect($inputs[2].element.checked).toBe(true)
415-
416-
expect(wrapper.emitted('update:modelValue')).toBeUndefined()
417-
418-
// Set internal value to new array reference
419-
wrapper.vm.localChecked = value.slice()
420-
await waitNT(wrapper.vm)
421-
422-
expect(wrapper.vm.modelValue).toEqual(value)
423-
expect($inputs[0].element.checked).toBe(true)
424-
expect($inputs[1].element.checked).toBe(true)
425-
expect($inputs[2].element.checked).toBe(true)
426-
427-
expect(wrapper.emitted('update:modelValue')).toBeUndefined()
428-
429-
// Set internal value to new array (reversed order)
430-
wrapper.vm.localChecked = value.slice().reverse()
431-
await waitNT(wrapper.vm)
432-
433-
expect(wrapper.vm.modelValue).toEqual(value.slice().reverse())
434-
expect($inputs[0].element.checked).toBe(true)
435-
expect($inputs[1].element.checked).toBe(true)
436-
expect($inputs[2].element.checked).toBe(true)
437-
expect(wrapper.emitted('update:modelValue')).toBeDefined()
438-
expect(wrapper.emitted('update:modelValue').length).toBe(1)
439-
expect(wrapper.emitted('update:modelValue')[0][0]).toEqual(value.slice().reverse())
440-
441-
wrapper.unmount()
442-
})
443-
444397
it('checkboxes reflect group checked v-model', async () => {
445398
const wrapper = mount(BFormCheckboxGroup, {
446399
attachTo: createContainer(),
@@ -455,13 +408,13 @@ describe('form-checkbox-group', () => {
455408

456409
const $inputs = wrapper.findAll('input[type=checkbox]')
457410
expect($inputs.length).toBe(3)
458-
expect(wrapper.vm.localChecked).toEqual(['two'])
411+
expect(wrapper.vm.modelValue).toEqual(['two'])
459412
expect($inputs[0].element.checked).toBe(false)
460413
expect($inputs[1].element.checked).toBe(true)
461414
expect($inputs[2].element.checked).toBe(false)
462415

463416
await wrapper.setProps({modelValue: ['three', 'one']})
464-
expect(wrapper.vm.localChecked).toEqual(['three', 'one'])
417+
expect(wrapper.vm.modelValue).toEqual(['three', 'one'])
465418
expect($inputs[0].element.checked).toBe(true)
466419
expect($inputs[1].element.checked).toBe(false)
467420
expect($inputs[2].element.checked).toBe(true)
@@ -481,7 +434,7 @@ describe('form-checkbox-group', () => {
481434
})
482435

483436
expect(wrapper.classes()).toBeDefined()
484-
expect(wrapper.vm.localChecked).toEqual([])
437+
expect(wrapper.vm.modelValue).toEqual([])
485438

486439
const $inputs = wrapper.findAll('input[type=checkbox]')
487440
expect($inputs.length).toBe(3)
@@ -503,7 +456,7 @@ describe('form-checkbox-group', () => {
503456
},
504457
})
505458

506-
expect(wrapper.vm.localChecked).toEqual([])
459+
expect(wrapper.vm.modelValue).toEqual([])
507460

508461
const $inputs = wrapper.findAll('input[type=checkbox]')
509462
expect($inputs.length).toBe(3)
@@ -525,7 +478,7 @@ describe('form-checkbox-group', () => {
525478
},
526479
})
527480

528-
expect(wrapper.vm.localChecked).toEqual([])
481+
expect(wrapper.vm.modelValue).toEqual([])
529482

530483
const $inputs = wrapper.findAll('input[type=checkbox]')
531484
expect($inputs.length).toBe(3)
@@ -548,7 +501,7 @@ describe('form-checkbox-group', () => {
548501
},
549502
})
550503

551-
expect(wrapper.vm.localChecked).toEqual([])
504+
expect(wrapper.vm.modelValue).toEqual([])
552505

553506
const $inputs = wrapper.findAll('input[type=checkbox]')
554507
expect($inputs.length).toBe(3)

0 commit comments

Comments
 (0)