From eeb18521c9a197f01988a77fd0347e978ed5418f Mon Sep 17 00:00:00 2001 From: R Midhun Suresh Date: Mon, 13 Jan 2025 02:51:54 +0530 Subject: [PATCH] Fix jest tests --- .../rooms/RoomHeader/highlight/useToggled.tsx | 2 +- .../__snapshots__/RoomView-test.tsx.snap | 15 +++++++++++++++ .../views/rooms/RoomHeader/RoomHeader-test.tsx | 8 +++++++- .../__snapshots__/RoomHeader-test.tsx.snap | 2 ++ .../VideoRoomChatButton-test.tsx.snap | 1 + 5 files changed, 26 insertions(+), 2 deletions(-) rename test/unit-tests/components/views/rooms/{ => RoomHeader}/__snapshots__/RoomHeader-test.tsx.snap (99%) diff --git a/src/components/views/rooms/RoomHeader/highlight/useToggled.tsx b/src/components/views/rooms/RoomHeader/highlight/useToggled.tsx index 28f36fe0f98..61908edcc67 100644 --- a/src/components/views/rooms/RoomHeader/highlight/useToggled.tsx +++ b/src/components/views/rooms/RoomHeader/highlight/useToggled.tsx @@ -16,7 +16,7 @@ import { CurrentRightPanelPhaseContext } from "../../../../../contexts/CurrentRi export function useToggled(phase: RightPanelPhases): boolean { const context = useContext(CurrentRightPanelPhaseContext); if (!context) { - throw new Error("Context is null, did you forget to use CurrentRightPanelPhaseContextProvider?"); + return false; } const { currentPhase, isPanelOpen } = context; return !!(isPanelOpen && currentPhase === phase); diff --git a/test/unit-tests/components/structures/__snapshots__/RoomView-test.tsx.snap b/test/unit-tests/components/structures/__snapshots__/RoomView-test.tsx.snap index 65a755058bf..eb775bdcbec 100644 --- a/test/unit-tests/components/structures/__snapshots__/RoomView-test.tsx.snap +++ b/test/unit-tests/components/structures/__snapshots__/RoomView-test.tsx.snap @@ -110,6 +110,7 @@ exports[`RoomView for a local room in state CREATING should match the snapshot 1 style="--cpd-icon-button-size: 100%;" > ({ + useCurrentPhase: () => { + return { currentPhase: "foo", isOpen: false }; + }, +})); function getWrapper(): RenderOptions { return { @@ -67,6 +72,7 @@ function getWrapper(): RenderOptions { }; } + describe("RoomHeader", () => { filterConsole( "[getType] Room !1:example.org does not have an m.room.create event", diff --git a/test/unit-tests/components/views/rooms/__snapshots__/RoomHeader-test.tsx.snap b/test/unit-tests/components/views/rooms/RoomHeader/__snapshots__/RoomHeader-test.tsx.snap similarity index 99% rename from test/unit-tests/components/views/rooms/__snapshots__/RoomHeader-test.tsx.snap rename to test/unit-tests/components/views/rooms/RoomHeader/__snapshots__/RoomHeader-test.tsx.snap index 3db3fb67fbf..6d0c2dc3e4a 100644 --- a/test/unit-tests/components/views/rooms/__snapshots__/RoomHeader-test.tsx.snap +++ b/test/unit-tests/components/views/rooms/RoomHeader/__snapshots__/RoomHeader-test.tsx.snap @@ -105,6 +105,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = ` style="--cpd-icon-button-size: 100%;" > renders button with an unread marker when room style="--cpd-icon-button-size: 100%;" >