Skip to content

Commit 073e85c

Browse files
committed
test(call): add test when crypto is enabled
1 parent 5fa0b04 commit 073e85c

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

spec/unit/webrtc/call.spec.ts

+29
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ import {
4848
import { CallFeed } from "../../../src/webrtc/callFeed";
4949
import { EventType, type IContent, type ISendEventResponse, type MatrixEvent, type Room } from "../../../src";
5050
import { emitPromise } from "../../test-utils/test-utils";
51+
import { CryptoApi } from "../../../src/crypto-api";
52+
import { GroupCallUnknownDeviceError } from "../../../src/webrtc/groupCall";
5153

5254
const FAKE_ROOM_ID = "!foo:bar";
5355
const CALL_LIFETIME = 60000;
@@ -1839,4 +1841,31 @@ describe("Call", function () {
18391841
const err = await prom;
18401842
expect(err.code).toBe(CallErrorCode.IceFailed);
18411843
});
1844+
1845+
it("should throw an error when trying to call 'placeCallWithCallFeeds' when crypto is enabled", async () => {
1846+
jest.spyOn(client.client, "getCrypto").mockReturnValue({} as unknown as CryptoApi);
1847+
call = new MatrixCall({
1848+
client: client.client,
1849+
roomId: FAKE_ROOM_ID,
1850+
opponentDeviceId: "opponent_device_id",
1851+
invitee: "invitee",
1852+
});
1853+
call.on(CallEvent.Error, jest.fn());
1854+
1855+
await expect(
1856+
call.placeCallWithCallFeeds([
1857+
new CallFeed({
1858+
client: client.client,
1859+
stream: new MockMediaStream("local_stream1", [
1860+
new MockMediaStreamTrack("track_id", "audio"),
1861+
]) as unknown as MediaStream,
1862+
userId: client.getUserId(),
1863+
deviceId: undefined,
1864+
purpose: SDPStreamMetadataPurpose.Usermedia,
1865+
audioMuted: false,
1866+
videoMuted: false,
1867+
}),
1868+
]),
1869+
).rejects.toThrow(new GroupCallUnknownDeviceError("invitee"));
1870+
});
18421871
});

0 commit comments

Comments
 (0)