Move mediaDevices
mock out of setupManualMocks
(#11413)
* Move `mediaDevices` mock out of `setupManualMocks` This doesn't work well in test suites with multiple tests, because the `mockReturnValue` is reset for subsequent tests. In any case, having it mocked out automagically is *magical*. Let's make it opt-in. * clarify ts-ignore
This commit is contained in:
parent
d569ba0cfe
commit
3fda0299a5
9 changed files with 34 additions and 15 deletions
|
@ -29,6 +29,7 @@ import {
|
|||
setupAsyncStoreWithClient,
|
||||
resetAsyncStoreWithClient,
|
||||
wrapInMatrixClientContext,
|
||||
useMockMediaDevices,
|
||||
} from "../../../test-utils";
|
||||
import defaultDispatcher from "../../../../src/dispatcher/dispatcher";
|
||||
import { Action } from "../../../../src/dispatcher/actions";
|
||||
|
@ -41,9 +42,6 @@ import { ConnectionState } from "../../../../src/models/Call";
|
|||
const CallEvent = wrapInMatrixClientContext(UnwrappedCallEvent);
|
||||
|
||||
describe("CallEvent", () => {
|
||||
useMockedCalls();
|
||||
jest.spyOn(HTMLMediaElement.prototype, "play").mockImplementation(async () => {});
|
||||
|
||||
let client: Mocked<MatrixClient>;
|
||||
let room: Room;
|
||||
let alice: RoomMember;
|
||||
|
@ -55,6 +53,10 @@ describe("CallEvent", () => {
|
|||
jest.useFakeTimers();
|
||||
jest.setSystemTime(0);
|
||||
|
||||
useMockMediaDevices();
|
||||
useMockedCalls();
|
||||
jest.spyOn(HTMLMediaElement.prototype, "play").mockImplementation(async () => {});
|
||||
|
||||
stubClient();
|
||||
client = mocked(MatrixClientPeg.safeGet());
|
||||
client.getUserId.mockReturnValue("@alice:example.org");
|
||||
|
|
|
@ -38,6 +38,7 @@ import {
|
|||
filterConsole,
|
||||
flushPromises,
|
||||
mkMessage,
|
||||
useMockMediaDevices,
|
||||
} from "../../../test-utils";
|
||||
import { CallStore } from "../../../../src/stores/CallStore";
|
||||
import RoomTile from "../../../../src/components/views/rooms/RoomTile";
|
||||
|
@ -134,6 +135,7 @@ describe("RoomTile", () => {
|
|||
};
|
||||
|
||||
beforeEach(() => {
|
||||
useMockMediaDevices();
|
||||
sdkContext = new TestSdkContext();
|
||||
|
||||
client = mocked(stubClient());
|
||||
|
|
|
@ -30,6 +30,7 @@ import {
|
|||
useMockedCalls,
|
||||
MockedCall,
|
||||
setupAsyncStoreWithClient,
|
||||
useMockMediaDevices,
|
||||
} from "../../../test-utils";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import { CallView as _CallView } from "../../../../src/components/views/voip/CallView";
|
||||
|
@ -41,7 +42,7 @@ import MediaDeviceHandler from "../../../../src/MediaDeviceHandler";
|
|||
|
||||
const CallView = wrapInMatrixClientContext(_CallView);
|
||||
|
||||
describe("CallLobby", () => {
|
||||
describe("CallView", () => {
|
||||
useMockedCalls();
|
||||
jest.spyOn(HTMLMediaElement.prototype, "play").mockImplementation(async () => {});
|
||||
|
||||
|
@ -50,7 +51,7 @@ describe("CallLobby", () => {
|
|||
let alice: RoomMember;
|
||||
|
||||
beforeEach(() => {
|
||||
mocked(navigator.mediaDevices.enumerateDevices).mockResolvedValue([]);
|
||||
useMockMediaDevices();
|
||||
|
||||
stubClient();
|
||||
client = mocked(MatrixClientPeg.safeGet());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue