From 5892b4e9fc23399b1462ee3481f426fbf816e4d7 Mon Sep 17 00:00:00 2001 From: Dave Batiste Date: Mon, 23 Sep 2024 17:07:50 -0400 Subject: [PATCH] Add unit tests for event. --- components/calendar/test/calendar.test.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/components/calendar/test/calendar.test.js b/components/calendar/test/calendar.test.js index b42b4b9a5fd..97041821e45 100644 --- a/components/calendar/test/calendar.test.js +++ b/components/calendar/test/calendar.test.js @@ -23,6 +23,7 @@ describe('d2l-calendar', () => { }); describe('events', () => { + it('dispatches event when date clicked', async() => { const calendar = await fixture(normalFixture); const el = calendar.shadowRoot.querySelector('td[data-date="1"] button'); @@ -92,6 +93,27 @@ describe('d2l-calendar', () => { const expectedFocusDate = new Date(2015, 8, 2); expect(calendar._focusDate).to.deep.equal(expectedFocusDate); }); + + it('dispatches d2l-calendar-view-change event when user changes to previous month', async() => { + const calendar = await fixture(normalFixture); + const el = calendar.shadowRoot.querySelectorAll('d2l-button-icon')[0]; + setTimeout(() => el.click()); + const { detail } = await oneEvent(calendar, 'd2l-calendar-view-change'); + await aTimeout(1); + expect(detail.minValue).to.deep.equal(new Date(2015, 6, 26)); + expect(detail.maxValue).to.deep.equal(new Date(2015, 8, 5)); + }); + + it('dispatches d2l-calendar-view-change event when user changes to next month', async() => { + const calendar = await fixture(normalFixture); + const el = calendar.shadowRoot.querySelectorAll('d2l-button-icon')[1]; + setTimeout(() => el.click()); + const { detail } = await oneEvent(calendar, 'd2l-calendar-view-change'); + await aTimeout(1); + expect(detail.minValue).to.deep.equal(new Date(2015, 8, 27)); + expect(detail.maxValue).to.deep.equal(new Date(2015, 9, 31)); + }); + }); describe('focus date', () => {