Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 03c8070

Browse files
committed
Fix tests for type changes
This is a conflict between #8104 and #8084
1 parent 953e314 commit 03c8070

File tree

3 files changed

+34
-10
lines changed

3 files changed

+34
-10
lines changed

test/components/views/rooms/MessageComposerButtons-test.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ function createRoomState(room: Room, narrow: boolean): IRoomState {
226226
matrixClientIsReady: false,
227227
timelineRenderingType: TimelineRenderingType.Room,
228228
liveTimeline: undefined,
229+
resizing: false,
229230
narrow,
230231
};
231232
}

test/components/views/rooms/RoomTile-test.tsx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@ limitations under the License.
1717
import React from "react";
1818
import { mount } from "enzyme";
1919
import { act } from "react-dom/test-utils";
20-
import { MatrixWidgetType } from "matrix-widget-api";
20+
import { ClientWidgetApi, MatrixWidgetType } from "matrix-widget-api";
2121

2222
import "../../../skinned-sdk";
2323
import { stubClient, mkStubRoom } from "../../../test-utils";
24-
import PlatformPeg from "../../../../src/PlatformPeg";
2524
import RoomTile from "../../../../src/components/views/rooms/RoomTile";
2625
import SettingsStore from "../../../../src/settings/SettingsStore";
2726
import WidgetStore from "../../../../src/stores/WidgetStore";
@@ -31,18 +30,33 @@ import VoiceChannelStore, { VoiceChannelEvent } from "../../../../src/stores/Voi
3130
import { DefaultTagID } from "../../../../src/stores/room-list/models";
3231
import DMRoomMap from "../../../../src/utils/DMRoomMap";
3332
import { VOICE_CHANNEL_ID } from "../../../../src/utils/VoiceChannelUtils";
33+
import { mocked } from "jest-mock";
34+
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
35+
import PlatformPeg from "../../../../src/PlatformPeg";
36+
import BasePlatform from "../../../../src/BasePlatform";
3437

3538
describe("RoomTile", () => {
36-
PlatformPeg.get = () => ({ overrideBrowserShortcuts: () => false });
37-
SettingsStore.getValue = setting => setting === "feature_voice_rooms";
39+
jest.spyOn(PlatformPeg, 'get')
40+
.mockReturnValue({ overrideBrowserShortcuts: () => false } as unknown as BasePlatform);
41+
42+
const cli = mocked(MatrixClientPeg.get());
43+
3844
beforeEach(() => {
45+
const realGetValue = SettingsStore.getValue;
46+
jest.spyOn(SettingsStore, 'getValue').mockImplementation((name, roomId) => {
47+
if (name === "feature_voice_rooms") {
48+
return true;
49+
}
50+
return realGetValue(name, roomId);
51+
});
52+
3953
stubClient();
4054
DMRoomMap.makeShared();
4155
});
4256

4357
describe("voice rooms", () => {
44-
const room = mkStubRoom("!1:example.org");
45-
room.isCallRoom.mockReturnValue(true);
58+
const room = mkStubRoom("!1:example.org", "voice room", cli);
59+
room.isCallRoom = () => true;
4660

4761
// Set up mocks to simulate the remote end of the widget API
4862
let messageSent;
@@ -72,7 +86,7 @@ describe("RoomTile", () => {
7286
send: messageSendMock,
7387
reply: () => {},
7488
},
75-
});
89+
} as unknown as ClientWidgetApi);
7690
});
7791

7892
it("tracks connection state", async () => {

test/components/views/voip/VoiceChannelRadio-test.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ import { stubClient, mkStubRoom, wrapInMatrixClientContext } from "../../../test
2424
import _VoiceChannelRadio from "../../../../src/components/views/voip/VoiceChannelRadio";
2525
import VoiceChannelStore, { VoiceChannelEvent } from "../../../../src/stores/VoiceChannelStore";
2626
import DMRoomMap from "../../../../src/utils/DMRoomMap";
27+
import { mocked } from "jest-mock";
28+
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
2729

2830
const VoiceChannelRadio = wrapInMatrixClientContext(_VoiceChannelRadio);
2931

@@ -64,17 +66,20 @@ class StubVoiceChannelStore extends EventEmitter {
6466
}
6567

6668
describe("VoiceChannelRadio", () => {
67-
const room = mkStubRoom("!1:example.org");
68-
room.isCallRoom.mockReturnValue(true);
69+
const cli = mocked(MatrixClientPeg.get());
70+
const room = mkStubRoom("!1:example.org", "voice channel", cli);
71+
room.isCallRoom = () => true;
6972

7073
beforeEach(() => {
7174
stubClient();
7275
DMRoomMap.makeShared();
7376
// Stub out the VoiceChannelStore
74-
jest.spyOn(VoiceChannelStore, "instance", "get").mockReturnValue(new StubVoiceChannelStore());
77+
jest.spyOn(VoiceChannelStore, "instance", "get")
78+
.mockReturnValue(new StubVoiceChannelStore() as unknown as VoiceChannelStore);
7579
});
7680

7781
it("shows when connecting voice", async () => {
82+
// @ts-ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
7883
const radio = mount(<VoiceChannelRadio />);
7984
expect(radio.children().children().exists()).toEqual(false);
8085

@@ -85,6 +90,7 @@ describe("VoiceChannelRadio", () => {
8590

8691
it("hides when disconnecting voice", () => {
8792
VoiceChannelStore.instance.connect("!1:example.org");
93+
// @ts-ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
8894
const radio = mount(<VoiceChannelRadio />);
8995
expect(radio.children().children().exists()).toEqual(true);
9096

@@ -96,6 +102,7 @@ describe("VoiceChannelRadio", () => {
96102
describe("disconnect button", () => {
97103
it("works", () => {
98104
VoiceChannelStore.instance.connect("!1:example.org");
105+
// @ts-ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
99106
const radio = mount(<VoiceChannelRadio />);
100107

101108
act(() => {
@@ -108,6 +115,7 @@ describe("VoiceChannelRadio", () => {
108115
describe("video button", () => {
109116
it("works", () => {
110117
VoiceChannelStore.instance.connect("!1:example.org");
118+
// @ts-ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
111119
const radio = mount(<VoiceChannelRadio />);
112120

113121
act(() => {
@@ -125,6 +133,7 @@ describe("VoiceChannelRadio", () => {
125133
describe("audio button", () => {
126134
it("works", () => {
127135
VoiceChannelStore.instance.connect("!1:example.org");
136+
// @ts-ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
128137
const radio = mount(<VoiceChannelRadio />);
129138

130139
act(() => {

0 commit comments

Comments
 (0)