diff --git a/components/tristatecheckbox/TriStateCheckbox.spec.js b/components/tristatecheckbox/TriStateCheckbox.spec.js index 3542daaeb..2bdccca0f 100644 --- a/components/tristatecheckbox/TriStateCheckbox.spec.js +++ b/components/tristatecheckbox/TriStateCheckbox.spec.js @@ -21,37 +21,8 @@ const emittedResults = [false, null, true]; describe('TriStateCheckbox.vue', () => { beforeEach(() => { wrapper = mount(TriStateCheckbox); - }), - describe('UpdateModel method tests', () => { - it('When disable props true updateModal should not triggered emit', async () => { - await wrapper.setProps({ - disabled: true, - modelValue: null - }); + }); - wrapper.vm.updateModel(); - - expect(wrapper.emitted()['update:modelValue']).toBeFalsy(); - }); - - it('When disable props false updateModal should triggered emit', () => { - wrapper.vm.updateModel(); - - expect(wrapper.emitted()['update:modelValue']).toBeTruthy(); - }); - - modelValues.forEach((modelValue, index) => { - it('When modelValue changed update model emitted value should be change', async () => { - await wrapper.setProps({ - modelValue - }); - - wrapper.vm.updateModel(); - - expect(wrapper.emitted()['update:modelValue']).toEqual([[emittedResults[index]]]); - }); - }); - }); it('When onClick method triggered some methods effect', () => { const mockUpdateModel = vi.fn(); @@ -87,6 +58,7 @@ describe('TriStateCheckbox.vue', () => { expect(wrapper.vm.focused).toBeFalsy(); expect(wrapper.emitted().blur).toBeTruthy(); }); + it('is icon changed', async () => { expect(wrapper.find('.p-checkbox-icon').classes()).not.toContain('pi-check'); expect(wrapper.find('.p-checkbox-icon').classes()).not.toContain('pi-times'); @@ -100,3 +72,38 @@ describe('TriStateCheckbox.vue', () => { expect(wrapper.find('.p-checkbox-icon').classes()).toContain('pi-times'); }); }); + +describe('UpdateModel method tests', () => { + beforeEach(() => { + wrapper = mount(TriStateCheckbox); + }); + + it('When disable props true updateModal should not triggered emit', async () => { + await wrapper.setProps({ + disabled: true, + modelValue: null + }); + + wrapper.vm.updateModel(); + + expect(wrapper.emitted()['update:modelValue']).toBeFalsy(); + }); + + it('When disable props false updateModal should triggered emit', async () => { + wrapper.vm.updateModel(); + + expect(wrapper.emitted()['update:modelValue']).toBeTruthy(); + }); + + modelValues.forEach((modelValue, index) => { + it('When modelValue changed update model emitted value should be change', async () => { + await wrapper.setProps({ + modelValue + }); + + wrapper.vm.updateModel(); + + expect(wrapper.emitted()['update:modelValue']).toEqual([[emittedResults[index]]]); + }); + }); +});