From 1c6cdb382b7d77ec8d2461fa84cc04194b8a88fb Mon Sep 17 00:00:00 2001 From: Camille Moussu Date: Thu, 28 Aug 2025 15:13:44 +0200 Subject: [PATCH] [#7] fixed test with incorect date gestion --- __test__/features/Events/EventDisplay.test.tsx | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/__test__/features/Events/EventDisplay.test.tsx b/__test__/features/Events/EventDisplay.test.tsx index 42190f4..093bfb7 100644 --- a/__test__/features/Events/EventDisplay.test.tsx +++ b/__test__/features/Events/EventDisplay.test.tsx @@ -7,7 +7,6 @@ import EventDisplayModal, { stringToColor, } from "../../../src/features/Events/EventDisplay"; import EventPreviewModal from "../../../src/features/Events/EventDisplayPreview"; - describe("Event Preview Display", () => { const mockOnClose = jest.fn(); const day = new Date(); @@ -479,7 +478,6 @@ describe("Event Preview Display", () => { describe("Event Full Display", () => { const mockOnClose = jest.fn(); const day = new Date(); - const RealDateToLocaleString = Date.prototype.toLocaleString; beforeEach(() => { jest.clearAllMocks(); @@ -554,15 +552,6 @@ describe("Event Full Display", () => { }; it("renders correctly event data", () => { - jest - .spyOn(Date.prototype, "toLocaleString") - .mockImplementation(function ( - this: Date, - locales?: Intl.LocalesArgument, - options?: Intl.DateTimeFormatOptions | undefined - ): string { - return RealDateToLocaleString.call(this, "en-UK", options); - }); renderWithProviders( { />, preloadedState ); - day.setHours(day.getHours() + 2); - const date = day.toISOString().slice(0, 16); + const tzOffset = day.getTimezoneOffset() * 60000; // offset in ms + const date = new Date(day.getTime() - tzOffset).toISOString().slice(0, 16); expect(screen.getByDisplayValue("Test Event")).toBeInTheDocument(); expect(