From eac718cfdca3bc24ba72669874364c8c22d198e8 Mon Sep 17 00:00:00 2001 From: Camille Moussu Date: Wed, 30 Jul 2025 15:23:00 +0200 Subject: [PATCH] [tests] removed noisy warnings --- src/components/Calendar/Calendar.tsx | 21 +++++++++++++-------- src/setupTests.ts | 13 +++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/components/Calendar/Calendar.tsx b/src/components/Calendar/Calendar.tsx index e647ac1..2018731 100644 --- a/src/components/Calendar/Calendar.tsx +++ b/src/components/Calendar/Calendar.tsx @@ -26,6 +26,7 @@ import { import { Calendars } from "../../features/Calendars/CalendarTypes"; import { push } from "redux-first-history"; import EventDisplayModal from "../../features/Events/EventDisplay"; +import { createSelector } from "@reduxjs/toolkit"; export default function CalendarApp() { const calendarRef = useRef(null); @@ -41,14 +42,18 @@ export default function CalendarApp() { const calendars = useAppSelector((state) => state.calendars.list); const pending = useAppSelector((state) => state.calendars.pending); const userId = useAppSelector((state) => state.user.userData.openpaasId); - - const userPersonnalCalendars: Calendars[] = useAppSelector((state) => - Object.keys(state.calendars.list).map((id) => { - if (id.split("/")[0] === userId) { - return state.calendars.list[id]; - } - return {} as Calendars; - }) + const selectPersonnalCalendars = createSelector( + (state) => state.calendars, + (calendars) => + Object.keys(calendars.list).map((id) => { + if (id.split("/")[0] === userId) { + return calendars.list[id]; + } + return {} as Calendars; + }) + ); + const userPersonnalCalendars: Calendars[] = useAppSelector( + selectPersonnalCalendars ); let personnalEvents: CalendarEvent[] = []; Object.keys(userPersonnalCalendars).forEach((value, id) => { diff --git a/src/setupTests.ts b/src/setupTests.ts index a68497d..aaccf0e 100644 --- a/src/setupTests.ts +++ b/src/setupTests.ts @@ -15,3 +15,16 @@ jest.mock("openid-client", () => ({ authorizationCodeGrant: jest.fn(), fetchUserInfo: jest.fn(), })); +const originalWarn = console.warn; + +beforeAll(() => { + console.warn = (...args: unknown[]) => { + if ( + typeof args[0] === "string" && + args[0].includes("React Router Future Flag Warning") + ) { + return; + } + originalWarn(...args); + }; +});