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

Commit 3a81bfe

Browse files
committed
more tests
Signed-off-by: Timo K <[email protected]>
1 parent b2f53cb commit 3a81bfe

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

test/components/views/beacon/RoomCallBanner-test.tsx

+10-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { CallStore } from "../../../../src/stores/CallStore";
4343
import { WidgetMessagingStore } from "../../../../src/stores/widgets/WidgetMessagingStore";
4444
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
4545
import { RoomViewStore } from "../../../../src/stores/RoomViewStore";
46+
import { ConnectionState } from "../../../../src/models/Call";
4647

4748
describe("<RoomLiveShareWarning />", () => {
4849
let client: Mocked<MatrixClient>;
@@ -119,11 +120,19 @@ describe("<RoomLiveShareWarning />", () => {
119120
expect(videoCallLabel.innerHTML).toBe("Video call");
120121
});
121122

122-
it("show Join button if the user has not joined", async () => {
123+
it("shows Join button if the user has not joined", async () => {
123124
await renderBanner();
124125
const videoCallLabel = await screen.findByText("Join");
125126
expect(videoCallLabel.innerHTML).toBe("Join");
126127
});
128+
129+
it("shows Leave button if the user has not joined", async () => {
130+
call.setConnectionState(ConnectionState.Connected);
131+
await renderBanner();
132+
const videoCallLabel = await screen.findByText("Leave");
133+
expect(videoCallLabel.innerHTML).toBe("Leave");
134+
});
135+
127136
it("dont show banner if the call is shown", async () => {
128137
jest.spyOn(RoomViewStore.instance, 'isViewingCall').mockReturnValue(false);
129138
await renderBanner();

test/test-utils/call.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type { Room } from "matrix-js-sdk/src/models/room";
2020
import type { RoomMember } from "matrix-js-sdk/src/models/room-member";
2121
import type { MatrixEvent } from "matrix-js-sdk/src/models/event";
2222
import { mkEvent } from "./test-utils";
23-
import { Call, ElementCall, JitsiCall } from "../../src/models/Call";
23+
import { Call, ConnectionState, ElementCall, JitsiCall } from "../../src/models/Call";
2424

2525
export class MockedCall extends Call {
2626
public static readonly EVENT_TYPE = "org.example.mocked_call";
@@ -68,6 +68,10 @@ export class MockedCall extends Call {
6868
super.participants = value;
6969
}
7070

71+
public setConnectionState(value: ConnectionState) {
72+
super.connectionState = value;
73+
}
74+
7175
// No action needed for any of the following methods since this is just a mock
7276
protected getDevices(): string[] { return []; }
7377
protected async setDevices(): Promise<void> { }

0 commit comments

Comments
 (0)