Skip to content

Commit eeb1852

Browse files
committed
Fix jest tests
1 parent 4eace4f commit eeb1852

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

src/components/views/rooms/RoomHeader/highlight/useToggled.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { CurrentRightPanelPhaseContext } from "../../../../../contexts/CurrentRi
1616
export function useToggled(phase: RightPanelPhases): boolean {
1717
const context = useContext(CurrentRightPanelPhaseContext);
1818
if (!context) {
19-
throw new Error("Context is null, did you forget to use CurrentRightPanelPhaseContextProvider?");
19+
return false;
2020
}
2121
const { currentPhase, isPanelOpen } = context;
2222
return !!(isPanelOpen && currentPhase === phase);

test/unit-tests/components/structures/__snapshots__/RoomView-test.tsx.snap

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ exports[`RoomView for a local room in state CREATING should match the snapshot 1
110110
style="--cpd-icon-button-size: 100%;"
111111
>
112112
<svg
113+
class=""
113114
fill="currentColor"
114115
height="1em"
115116
viewBox="0 0 24 24"
@@ -135,6 +136,7 @@ exports[`RoomView for a local room in state CREATING should match the snapshot 1
135136
style="--cpd-icon-button-size: 100%;"
136137
>
137138
<svg
139+
class=""
138140
fill="currentColor"
139141
height="1em"
140142
viewBox="0 0 24 24"
@@ -323,6 +325,7 @@ exports[`RoomView for a local room in state ERROR should match the snapshot 1`]
323325
style="--cpd-icon-button-size: 100%;"
324326
>
325327
<svg
328+
class=""
326329
fill="currentColor"
327330
height="1em"
328331
viewBox="0 0 24 24"
@@ -348,6 +351,7 @@ exports[`RoomView for a local room in state ERROR should match the snapshot 1`]
348351
style="--cpd-icon-button-size: 100%;"
349352
>
350353
<svg
354+
class=""
351355
fill="currentColor"
352356
height="1em"
353357
viewBox="0 0 24 24"
@@ -621,6 +625,7 @@ exports[`RoomView for a local room in state NEW should match the snapshot 1`] =
621625
style="--cpd-icon-button-size: 100%;"
622626
>
623627
<svg
628+
class=""
624629
fill="currentColor"
625630
height="1em"
626631
viewBox="0 0 24 24"
@@ -646,6 +651,7 @@ exports[`RoomView for a local room in state NEW should match the snapshot 1`] =
646651
style="--cpd-icon-button-size: 100%;"
647652
>
648653
<svg
654+
class=""
649655
fill="currentColor"
650656
height="1em"
651657
viewBox="0 0 24 24"
@@ -996,6 +1002,7 @@ exports[`RoomView for a local room in state NEW that is encrypted should match t
9961002
style="--cpd-icon-button-size: 100%;"
9971003
>
9981004
<svg
1005+
class=""
9991006
fill="currentColor"
10001007
height="1em"
10011008
viewBox="0 0 24 24"
@@ -1021,6 +1028,7 @@ exports[`RoomView for a local room in state NEW that is encrypted should match t
10211028
style="--cpd-icon-button-size: 100%;"
10221029
>
10231030
<svg
1031+
class=""
10241032
fill="currentColor"
10251033
height="1em"
10261034
viewBox="0 0 24 24"
@@ -1379,6 +1387,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
13791387
style="--cpd-icon-button-size: 100%;"
13801388
>
13811389
<svg
1390+
class=""
13821391
fill="currentColor"
13831392
height="1em"
13841393
viewBox="0 0 24 24"
@@ -1404,6 +1413,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
14041413
style="--cpd-icon-button-size: 100%;"
14051414
>
14061415
<svg
1416+
class=""
14071417
fill="currentColor"
14081418
height="1em"
14091419
viewBox="0 0 24 24"
@@ -1585,6 +1595,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
15851595
style="--cpd-icon-button-size: 100%;"
15861596
>
15871597
<svg
1598+
class=""
15881599
fill="currentColor"
15891600
height="1em"
15901601
viewBox="0 0 24 24"
@@ -1610,6 +1621,7 @@ exports[`RoomView should not display the timeline when the room encryption is lo
16101621
style="--cpd-icon-button-size: 100%;"
16111622
>
16121623
<svg
1624+
class=""
16131625
fill="currentColor"
16141626
height="1em"
16151627
viewBox="0 0 24 24"
@@ -1912,6 +1924,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
19121924
style="--cpd-icon-button-size: 100%;"
19131925
>
19141926
<svg
1927+
class="mx_RoomHeader_toggled"
19151928
fill="currentColor"
19161929
height="1em"
19171930
viewBox="0 0 24 24"
@@ -1937,6 +1950,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
19371950
style="--cpd-icon-button-size: 100%;"
19381951
>
19391952
<svg
1953+
class=""
19401954
fill="currentColor"
19411955
height="1em"
19421956
viewBox="0 0 24 24"
@@ -1962,6 +1976,7 @@ exports[`RoomView video rooms should render joined video room view 1`] = `
19621976
style="--cpd-icon-button-size: 100%;"
19631977
>
19641978
<svg
1979+
class=""
19651980
fill="currentColor"
19661981
height="1em"
19671982
viewBox="0 0 24 24"

test/unit-tests/components/views/rooms/RoomHeader/RoomHeader-test.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,12 @@ import { SdkContextClass } from "../../../../../../src/contexts/SDKContext";
5757
import WidgetStore, { IApp } from "../../../../../../src/stores/WidgetStore";
5858
import { UIFeature } from "../../../../../../src/settings/UIFeature";
5959

60-
jest.mock("../../../../../src/utils/ShieldUtils");
60+
jest.mock("../../../../../../src/utils/ShieldUtils");
61+
jest.mock("../../../../../../src/hooks/right-panel/useCurrentPhase", () => ({
62+
useCurrentPhase: () => {
63+
return { currentPhase: "foo", isOpen: false };
64+
},
65+
}));
6166

6267
function getWrapper(): RenderOptions {
6368
return {
@@ -67,6 +72,7 @@ function getWrapper(): RenderOptions {
6772
};
6873
}
6974

75+
7076
describe("RoomHeader", () => {
7177
filterConsole(
7278
"[getType] Room !1:example.org does not have an m.room.create event",

test/unit-tests/components/views/rooms/__snapshots__/RoomHeader-test.tsx.snap renamed to test/unit-tests/components/views/rooms/RoomHeader/__snapshots__/RoomHeader-test.tsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = `
105105
style="--cpd-icon-button-size: 100%;"
106106
>
107107
<svg
108+
class=""
108109
fill="currentColor"
109110
height="1em"
110111
viewBox="0 0 24 24"
@@ -130,6 +131,7 @@ exports[`RoomHeader dm does not show the face pile for DMs 1`] = `
130131
style="--cpd-icon-button-size: 100%;"
131132
>
132133
<svg
134+
class=""
133135
fill="currentColor"
134136
height="1em"
135137
viewBox="0 0 24 24"

test/unit-tests/components/views/rooms/RoomHeader/__snapshots__/VideoRoomChatButton-test.tsx.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ exports[`<VideoRoomChatButton /> renders button with an unread marker when room
1616
style="--cpd-icon-button-size: 100%;"
1717
>
1818
<svg
19+
class=""
1920
fill="currentColor"
2021
height="1em"
2122
viewBox="0 0 24 24"

0 commit comments

Comments
 (0)