You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-07-31 15:24:23 +03:00
Add tests for falling back to answering with no video
Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
@ -100,6 +100,11 @@ class MockMediaDeviceInfo {
|
|||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class MockMediaHandler {
|
||||||
|
getUserMediaStream() { return new MockMediaStream("mock_stream_from_media_handler"); }
|
||||||
|
stopUserMediaStream() {}
|
||||||
|
}
|
||||||
|
|
||||||
describe('Call', function() {
|
describe('Call', function() {
|
||||||
let client;
|
let client;
|
||||||
let call;
|
let call;
|
||||||
@ -137,6 +142,8 @@ describe('Call', function() {
|
|||||||
// We just stub out sendEvent: we're not interested in testing the client's
|
// We just stub out sendEvent: we're not interested in testing the client's
|
||||||
// event sending code here
|
// event sending code here
|
||||||
client.client.sendEvent = () => {};
|
client.client.sendEvent = () => {};
|
||||||
|
client.client.mediaHandler = new MockMediaHandler;
|
||||||
|
client.client.getMediaHandler = () => client.client.mediaHandler;
|
||||||
client.httpBackend.when("GET", "/voip/turnServer").respond(200, {});
|
client.httpBackend.when("GET", "/voip/turnServer").respond(200, {});
|
||||||
call = new MatrixCall({
|
call = new MatrixCall({
|
||||||
client: client.client,
|
client: client.client,
|
||||||
@ -376,4 +383,16 @@ describe('Call', function() {
|
|||||||
call.setScreensharingEnabled(true);
|
call.setScreensharingEnabled(true);
|
||||||
expect(call.setScreensharingEnabledWithoutMetadataSupport).toHaveBeenCalled();
|
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);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user