test(02-04): CalendarShell CAL-03 render smoke — Temporal hydration + Pitfall 6 guard
- CalendarShell.test.tsx: 6 tests covering render-without-throw, ScheduleXCalendar mount, hydrateEvents called with both timed + all-day occurrences, Temporal.PlainDate guard (Pitfall 4/all-day date shift), Temporal.ZonedDateTime for timed (Pitfall 4) - test-setup.ts: window.matchMedia polyfill for jsdom (calendarStore initialises at module load) - vitest.config.ts: adds setupFiles pointing to test-setup.ts
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
/**
|
||||
* Vitest global test setup for apps/pwa.
|
||||
*
|
||||
* This file runs before each test file, before module imports that trigger
|
||||
* module-level side effects (e.g. Zustand store initialisation calls
|
||||
* window.matchMedia at create() time).
|
||||
*
|
||||
* Polyfills required for jsdom:
|
||||
* - window.matchMedia: used by calendarStore to resolve the default view
|
||||
* from viewport width at store initialisation time.
|
||||
*/
|
||||
|
||||
// Polyfill window.matchMedia for jsdom.
|
||||
// jsdom does not implement the CSSOM MediaQueryList API.
|
||||
// calendarStore.ts calls window.matchMedia during Zustand create(), so this
|
||||
// must be set before the store module is imported in any test.
|
||||
Object.defineProperty(window, 'matchMedia', {
|
||||
writable: true,
|
||||
value: (query: string) => ({
|
||||
matches: false, // tablet-desktop default — week-start-day tests are unaffected
|
||||
media: query,
|
||||
onchange: null,
|
||||
addListener: () => undefined,
|
||||
removeListener: () => undefined,
|
||||
addEventListener: () => undefined,
|
||||
removeEventListener: () => undefined,
|
||||
dispatchEvent: () => false,
|
||||
}),
|
||||
})
|
||||
Reference in New Issue
Block a user