From 656d3de3e96b66669e814b336063e01540d934d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=20=C3=96sterlund?= Date: Thu, 30 Nov 2023 18:40:17 +0100 Subject: [PATCH] test: add unit test for new public method goToPeriod --- tests/unit/components/Qalendar.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/unit/components/Qalendar.test.ts b/tests/unit/components/Qalendar.test.ts index c7735ad4..3dec91a1 100644 --- a/tests/unit/components/Qalendar.test.ts +++ b/tests/unit/components/Qalendar.test.ts @@ -480,4 +480,15 @@ describe('Qalendar.vue', () => { month.vm.$emit('updated-period', { start: new Date(), end: new Date(), selectedDate: new Date() }) expect(wrapper.vm.mode).toBe('day') }) + + it('should go to invoke the goToPeriod in the header and go forward in time', () => { + const wrapper = mount(Qalendar) + const header = wrapper.findComponent({ name: 'AppHeader' }) + const goToPeriodSpy = vi.spyOn(header.vm, 'goToPeriod') + const expectedDirection = 'forward' + + wrapper.vm.goToPeriod(expectedDirection) + + expect(goToPeriodSpy).toHaveBeenCalledWith(expectedDirection) + }) })