Skip to content

Commit

Permalink
test: add unit test for new public method goToPeriod
Browse files Browse the repository at this point in the history
  • Loading branch information
tomosterlund committed Nov 30, 2023
1 parent e75f3b4 commit 656d3de
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/unit/components/Qalendar.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
})

0 comments on commit 656d3de

Please sign in to comment.