From 9f157ac3caec921fbec530cef099fd759c928ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Fri, 9 Dec 2022 12:18:21 +0300 Subject: [PATCH] Update TriStateCheckbox.spec.js --- .../tristatecheckbox/TriStateCheckbox.spec.js | 67 ++++++++++--------- 1 file changed, 37 insertions(+), 30 deletions(-) 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]]]); + }); + }); +});