Skip to content

Commit

Permalink
test(call): add test when crypto is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Feb 6, 2025
1 parent 5fa0b04 commit 2e83fea
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions spec/unit/webrtc/call.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ import {
import { CallFeed } from "../../../src/webrtc/callFeed";
import { EventType, type IContent, type ISendEventResponse, type MatrixEvent, type Room } from "../../../src";
import { emitPromise } from "../../test-utils/test-utils";
import type { CryptoApi } from "../../../src/crypto-api";
import { GroupCallUnknownDeviceError } from "../../../src/webrtc/groupCall";

const FAKE_ROOM_ID = "!foo:bar";
const CALL_LIFETIME = 60000;
Expand Down Expand Up @@ -1839,4 +1841,31 @@ describe("Call", function () {
const err = await prom;
expect(err.code).toBe(CallErrorCode.IceFailed);
});

it("should throw an error when trying to call 'placeCallWithCallFeeds' when crypto is enabled", async () => {
jest.spyOn(client.client, "getCrypto").mockReturnValue({} as unknown as CryptoApi);
call = new MatrixCall({
client: client.client,
roomId: FAKE_ROOM_ID,
opponentDeviceId: "opponent_device_id",
invitee: "invitee",
});
call.on(CallEvent.Error, jest.fn());

await expect(
call.placeCallWithCallFeeds([
new CallFeed({
client: client.client,
stream: new MockMediaStream("local_stream1", [
new MockMediaStreamTrack("track_id", "audio"),
]) as unknown as MediaStream,
userId: client.getUserId(),
deviceId: undefined,
purpose: SDPStreamMetadataPurpose.Usermedia,
audioMuted: false,
videoMuted: false,
}),
]),
).rejects.toThrow(new GroupCallUnknownDeviceError("invitee"));
});
});

0 comments on commit 2e83fea

Please sign in to comment.