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

Commit 8b09e7d

Browse files
committed
add test
1 parent 13404e5 commit 8b09e7d

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

test/Notifier-test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {
2626
SyncState,
2727
} from "matrix-js-sdk/src/matrix";
2828
import { waitFor } from "@testing-library/react";
29+
// eslint-disable-next-line no-restricted-imports
30+
import { MatrixRTCSession } from "matrix-js-sdk/src/matrixrtc/MatrixRTCSession";
2931

3032
import BasePlatform from "../src/BasePlatform";
3133
import Notifier from "../src/Notifier";
@@ -53,6 +55,8 @@ import { Action } from "../src/dispatcher/actions";
5355
import { VoiceBroadcastChunkEventType, VoiceBroadcastInfoState } from "../src/voice-broadcast";
5456
import { mkVoiceBroadcastInfoStateEvent } from "./voice-broadcast/utils/test-utils";
5557
import { addReplyToMessageContent } from "../src/utils/Reply";
58+
import { CallStore } from "../src/stores/CallStore";
59+
import { Call, ElementCall } from "../src/models/Call";
5660

5761
jest.mock("../src/utils/notifications", () => ({
5862
// @ts-ignore
@@ -139,6 +143,11 @@ describe("Notifier", () => {
139143
getRoom: jest.fn(),
140144
getPushActionsForEvent: jest.fn(),
141145
supportsThreads: jest.fn().mockReturnValue(false),
146+
matrixRTC: {
147+
on: jest.fn(),
148+
off: jest.fn(),
149+
getRoomSession: jest.fn(),
150+
},
142151
});
143152

144153
mockClient.pushRules = {
@@ -455,6 +464,23 @@ describe("Notifier", () => {
455464
expect(ToastStore.sharedInstance().addOrReplaceToast).not.toHaveBeenCalled();
456465
});
457466

467+
it("should not show toast when group call is already connected", () => {
468+
setGroupCallsEnabled(true);
469+
const roomSession = MatrixRTCSession.roomSessionForRoom(mockClient, testRoom);
470+
const spyCallId = jest.spyOn(roomSession, "callId", "get").mockReturnValue("abc123");
471+
472+
mockClient.matrixRTC.getRoomSession.mockReturnValue(roomSession);
473+
ElementCall.create(testRoom);
474+
const mockedElementCall = Call.get(testRoom)!;
475+
const spyConnectedCalls = jest
476+
.spyOn(CallStore.instance, "connectedCalls", "get")
477+
.mockReturnValue(new Set([mockedElementCall]));
478+
emitCallNotifyEvent();
479+
expect(ToastStore.sharedInstance().addOrReplaceToast).not.toHaveBeenCalled();
480+
spyCallId.mockRestore();
481+
spyConnectedCalls.mockRestore();
482+
});
483+
458484
it("should not show toast when calling with non-group call event", () => {
459485
setGroupCallsEnabled(true);
460486

0 commit comments

Comments
 (0)