From 112c61ab1cc3f1a05b60020f983a506f12d09f8e Mon Sep 17 00:00:00 2001 From: Flea Flicker Date: Tue, 26 May 2026 13:06:07 +0000 Subject: [PATCH] fix: add non-null assertion on listener.mock.calls[0] (TS strict mode) Lines 28 and 40 access mock.calls[0] which is possibly undefined under strict TypeScript. Adding ! to satisfy TS2532. Co-Authored-By: Paperclip --- src/__tests__/analytics.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/__tests__/analytics.test.ts b/src/__tests__/analytics.test.ts index e8621b5..f24dd11 100644 --- a/src/__tests__/analytics.test.ts +++ b/src/__tests__/analytics.test.ts @@ -25,7 +25,7 @@ describe("analytics", () => { window.addEventListener(ANALYTICS_EVENTS.BOOKING_STEP_SERVICE, listener); fireAnalyticsEvent(ANALYTICS_EVENTS.BOOKING_STEP_SERVICE, { step: "service", flow: "public" }); expect(listener).toHaveBeenCalledTimes(1); - const event = listener.mock.calls[0][0] as CustomEvent; + const event = listener.mock.calls[0]![0] as CustomEvent; expect(event.type).toBe("booking_step_service"); expect(event.detail.step).toBe("service"); expect(event.detail.flow).toBe("public"); @@ -37,7 +37,7 @@ describe("analytics", () => { const listener = vi.fn(); window.addEventListener(ANALYTICS_EVENTS.BOOKING_CONFIRMED, listener); fireAnalyticsEvent(ANALYTICS_EVENTS.BOOKING_CONFIRMED, { step: "confirmed", flow: "public" }); - const event = listener.mock.calls[0][0] as CustomEvent; + const event = listener.mock.calls[0]![0] as CustomEvent; expect(event.detail.timestamp).toBeTruthy(); expect(new Date(event.detail.timestamp as string)).toBeInstanceOf(Date); window.removeEventListener(ANALYTICS_EVENTS.BOOKING_CONFIRMED, listener);