From 3aefc9f02e68fd0ac47d2e91c64ce246e6dd012c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0imon=20Brandner?= Date: Thu, 14 Oct 2021 08:46:36 +0200 Subject: [PATCH] Add tests for falling back to answering with no video MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Šimon Brandner --- spec/unit/webrtc/call.spec.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/unit/webrtc/call.spec.ts b/spec/unit/webrtc/call.spec.ts index 61b58ac30..9e12db20f 100644 --- a/spec/unit/webrtc/call.spec.ts +++ b/spec/unit/webrtc/call.spec.ts @@ -100,6 +100,11 @@ class MockMediaDeviceInfo { ) {} } +class MockMediaHandler { + getUserMediaStream() { return new MockMediaStream("mock_stream_from_media_handler"); } + stopUserMediaStream() {} +} + describe('Call', function() { let client; let call; @@ -137,6 +142,8 @@ describe('Call', function() { // We just stub out sendEvent: we're not interested in testing the client's // event sending code here client.client.sendEvent = () => {}; + client.client.mediaHandler = new MockMediaHandler; + client.client.getMediaHandler = () => client.client.mediaHandler; client.httpBackend.when("GET", "/voip/turnServer").respond(200, {}); call = new MatrixCall({ client: client.client, @@ -376,4 +383,16 @@ describe('Call', function() { call.setScreensharingEnabled(true); expect(call.setScreensharingEnabledWithoutMetadataSupport).toHaveBeenCalled(); }); + + it("should fallback to answering with no video", async () => { + await client.httpBackend.flush(); + + call.shouldAnswerWithMediaType = (wantedValue: boolean) => wantedValue; + client.client.mediaHandler.getUserMediaStream = jest.fn().mockRejectedValue("reject"); + + await call.answer(true, true); + + expect(client.client.mediaHandler.getUserMediaStream).toHaveBeenNthCalledWith(1, true, true); + expect(client.client.mediaHandler.getUserMediaStream).toHaveBeenNthCalledWith(2, true, false); + }); });