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

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
toger5 committed Oct 17, 2022
1 parent 45e7e13 commit 95442c9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 10 additions & 1 deletion test/components/views/beacon/RoomCallBanner-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { CallStore } from "../../../../src/stores/CallStore";
import { WidgetMessagingStore } from "../../../../src/stores/widgets/WidgetMessagingStore";
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
import { RoomViewStore } from "../../../../src/stores/RoomViewStore";
import { ConnectionState } from "../../../../src/models/Call";

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

it("show Join button if the user has not joined", async () => {
it("shows Join button if the user has not joined", async () => {
await renderBanner();
const videoCallLabel = await screen.findByText("Join");
expect(videoCallLabel.innerHTML).toBe("Join");
});

it("shows Leave button if the user has not joined", async () => {
call.setConnectionState(ConnectionState.Connected);
await renderBanner();
const videoCallLabel = await screen.findByText("Leave");
expect(videoCallLabel.innerHTML).toBe("Leave");
});

it("dont show banner if the call is shown", async () => {
jest.spyOn(RoomViewStore.instance, 'isViewingCall').mockReturnValue(false);
await renderBanner();
Expand Down
6 changes: 5 additions & 1 deletion test/test-utils/call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type { Room } from "matrix-js-sdk/src/models/room";
import type { RoomMember } from "matrix-js-sdk/src/models/room-member";
import type { MatrixEvent } from "matrix-js-sdk/src/models/event";
import { mkEvent } from "./test-utils";
import { Call, ElementCall, JitsiCall } from "../../src/models/Call";
import { Call, ConnectionState, ElementCall, JitsiCall } from "../../src/models/Call";

export class MockedCall extends Call {
public static readonly EVENT_TYPE = "org.example.mocked_call";
Expand Down Expand Up @@ -68,6 +68,10 @@ export class MockedCall extends Call {
super.participants = value;
}

public setConnectionState(value: ConnectionState) {
super.connectionState = value;
}

// No action needed for any of the following methods since this is just a mock
protected getDevices(): string[] { return []; }
protected async setDevices(): Promise<void> { }
Expand Down

0 comments on commit 95442c9

Please sign in to comment.