Make most params optional for call view model test setup

This commit is contained in:
Robin
2025-08-22 18:10:17 +02:00
parent 482e2f8f6f
commit db65a5308a

View File

@@ -233,12 +233,22 @@ function summarizeLayout$(l$: Observable<Layout>): Observable<LayoutSummary> {
); );
} }
interface CallViewModelInputs {
remoteParticipants$: Behavior<RemoteParticipant[]>;
rtcMembers$: Behavior<Partial<CallMembership>[]>;
connectionState$: Observable<ECConnectionState>;
speaking: Map<Participant, Observable<boolean>>;
mediaDevices: MediaDevices;
}
function withCallViewModel( function withCallViewModel(
remoteParticipants$: Behavior<RemoteParticipant[]>, {
rtcMembers$: Behavior<Partial<CallMembership>[]>, remoteParticipants$ = constant([]),
connectionState$: Observable<ECConnectionState>, rtcMembers$ = constant([localRtcMember]),
speaking: Map<Participant, Observable<boolean>>, connectionState$ = of(ConnectionState.Connected),
mediaDevices: MediaDevices, speaking = new Map(),
mediaDevices = mockMediaDevices({}),
}: Partial<CallViewModelInputs>,
continuation: ( continuation: (
vm: CallViewModel, vm: CallViewModel,
rtcSession: MockRTCSession, rtcSession: MockRTCSession,
@@ -324,17 +334,17 @@ test("participants are retained during a focus switch", () => {
const expectedLayoutMarbles = " a"; const expectedLayoutMarbles = " a";
withCallViewModel( withCallViewModel(
behavior(participantInputMarbles, { {
remoteParticipants$: behavior(participantInputMarbles, {
a: [aliceParticipant, bobParticipant], a: [aliceParticipant, bobParticipant],
b: [], b: [],
}), }),
constant([localRtcMember, aliceRtcMember, bobRtcMember]), rtcMembers$: constant([localRtcMember, aliceRtcMember, bobRtcMember]),
behavior(connectionInputMarbles, { connectionState$: behavior(connectionInputMarbles, {
c: ConnectionState.Connected, c: ConnectionState.Connected,
s: ECAddonConnectionState.ECSwitchingFocus, s: ECAddonConnectionState.ECSwitchingFocus,
}), }),
new Map(), },
mockMediaDevices({}),
(vm) => { (vm) => {
expectObservable(summarizeLayout$(vm.layout$)).toBe( expectObservable(summarizeLayout$(vm.layout$)).toBe(
expectedLayoutMarbles, expectedLayoutMarbles,
@@ -365,16 +375,15 @@ test("screen sharing activates spotlight layout", () => {
const expectedLayoutMarbles = " abcdaefeg"; const expectedLayoutMarbles = " abcdaefeg";
const expectedShowSpeakingMarbles = "y----nyny"; const expectedShowSpeakingMarbles = "y----nyny";
withCallViewModel( withCallViewModel(
behavior(participantInputMarbles, { {
remoteParticipants$: behavior(participantInputMarbles, {
a: [aliceParticipant, bobParticipant], a: [aliceParticipant, bobParticipant],
b: [aliceSharingScreen, bobParticipant], b: [aliceSharingScreen, bobParticipant],
c: [aliceSharingScreen, bobSharingScreen], c: [aliceSharingScreen, bobSharingScreen],
d: [aliceParticipant, bobSharingScreen], d: [aliceParticipant, bobSharingScreen],
}), }),
constant([localRtcMember, aliceRtcMember, bobRtcMember]), rtcMembers$: constant([localRtcMember, aliceRtcMember, bobRtcMember]),
of(ConnectionState.Connected), },
new Map(),
mockMediaDevices({}),
(vm) => { (vm) => {
schedule(modeInputMarbles, { schedule(modeInputMarbles, {
s: () => vm.setGridMode("spotlight"), s: () => vm.setGridMode("spotlight"),
@@ -447,15 +456,24 @@ test("participants stay in the same order unless to appear/disappear", () => {
const expectedLayoutMarbles = " a 1999ms b 1999ms a 57999ms c 1999ms a"; const expectedLayoutMarbles = " a 1999ms b 1999ms a 57999ms c 1999ms a";
withCallViewModel( withCallViewModel(
constant([aliceParticipant, bobParticipant, daveParticipant]), {
constant([localRtcMember, aliceRtcMember, bobRtcMember, daveRtcMember]), remoteParticipants$: constant([
of(ConnectionState.Connected), aliceParticipant,
new Map([ bobParticipant,
daveParticipant,
]),
rtcMembers$: constant([
localRtcMember,
aliceRtcMember,
bobRtcMember,
daveRtcMember,
]),
speaking: new Map([
[aliceParticipant, behavior(aSpeakingInputMarbles, yesNo)], [aliceParticipant, behavior(aSpeakingInputMarbles, yesNo)],
[bobParticipant, behavior(bSpeakingInputMarbles, yesNo)], [bobParticipant, behavior(bSpeakingInputMarbles, yesNo)],
[daveParticipant, behavior(dSpeakingInputMarbles, yesNo)], [daveParticipant, behavior(dSpeakingInputMarbles, yesNo)],
]), ]),
mockMediaDevices({}), },
(vm) => { (vm) => {
schedule(visibilityInputMarbles, { schedule(visibilityInputMarbles, {
a: () => { a: () => {
@@ -505,14 +523,23 @@ test("participants adjust order when space becomes constrained", () => {
const expectedLayoutMarbles = " a-b"; const expectedLayoutMarbles = " a-b";
withCallViewModel( withCallViewModel(
constant([aliceParticipant, bobParticipant, daveParticipant]), {
constant([localRtcMember, aliceRtcMember, bobRtcMember, daveRtcMember]), remoteParticipants$: constant([
of(ConnectionState.Connected), aliceParticipant,
new Map([ bobParticipant,
daveParticipant,
]),
rtcMembers$: constant([
localRtcMember,
aliceRtcMember,
bobRtcMember,
daveRtcMember,
]),
speaking: new Map([
[bobParticipant, behavior(bSpeakingInputMarbles, yesNo)], [bobParticipant, behavior(bSpeakingInputMarbles, yesNo)],
[daveParticipant, behavior(dSpeakingInputMarbles, yesNo)], [daveParticipant, behavior(dSpeakingInputMarbles, yesNo)],
]), ]),
mockMediaDevices({}), },
(vm) => { (vm) => {
let setVisibleTiles: ((value: number) => void) | null = null; let setVisibleTiles: ((value: number) => void) | null = null;
vm.layout$.subscribe((layout) => { vm.layout$.subscribe((layout) => {
@@ -558,15 +585,24 @@ test("spotlight speakers swap places", () => {
const expectedLayoutMarbles = "abcd"; const expectedLayoutMarbles = "abcd";
withCallViewModel( withCallViewModel(
constant([aliceParticipant, bobParticipant, daveParticipant]), {
constant([localRtcMember, aliceRtcMember, bobRtcMember, daveRtcMember]), remoteParticipants$: constant([
of(ConnectionState.Connected), aliceParticipant,
new Map([ bobParticipant,
daveParticipant,
]),
rtcMembers$: constant([
localRtcMember,
aliceRtcMember,
bobRtcMember,
daveRtcMember,
]),
speaking: new Map([
[aliceParticipant, behavior(aSpeakingInputMarbles, yesNo)], [aliceParticipant, behavior(aSpeakingInputMarbles, yesNo)],
[bobParticipant, behavior(bSpeakingInputMarbles, yesNo)], [bobParticipant, behavior(bSpeakingInputMarbles, yesNo)],
[daveParticipant, behavior(dSpeakingInputMarbles, yesNo)], [daveParticipant, behavior(dSpeakingInputMarbles, yesNo)],
]), ]),
mockMediaDevices({}), },
(vm) => { (vm) => {
schedule(modeInputMarbles, { s: () => vm.setGridMode("spotlight") }); schedule(modeInputMarbles, { s: () => vm.setGridMode("spotlight") });
@@ -608,11 +644,10 @@ test("layout enters picture-in-picture mode when requested", () => {
const expectedLayoutMarbles = " aba"; const expectedLayoutMarbles = " aba";
withCallViewModel( withCallViewModel(
constant([aliceParticipant, bobParticipant]), {
constant([localRtcMember, aliceRtcMember, bobRtcMember]), remoteParticipants$: constant([aliceParticipant, bobParticipant]),
of(ConnectionState.Connected), rtcMembers$: constant([localRtcMember, aliceRtcMember, bobRtcMember]),
new Map(), },
mockMediaDevices({}),
(vm) => { (vm) => {
schedule(pipControlInputMarbles, { schedule(pipControlInputMarbles, {
e: () => window.controls.enablePip(), e: () => window.controls.enablePip(),
@@ -650,11 +685,10 @@ test("spotlight remembers whether it's expanded", () => {
const expectedLayoutMarbles = "abcbada"; const expectedLayoutMarbles = "abcbada";
withCallViewModel( withCallViewModel(
constant([aliceParticipant, bobParticipant]), {
constant([localRtcMember, aliceRtcMember, bobRtcMember]), remoteParticipants$: constant([aliceParticipant, bobParticipant]),
of(ConnectionState.Connected), rtcMembers$: constant([localRtcMember, aliceRtcMember, bobRtcMember]),
new Map(), },
mockMediaDevices({}),
(vm) => { (vm) => {
schedule(modeInputMarbles, { schedule(modeInputMarbles, {
s: () => vm.setGridMode("spotlight"), s: () => vm.setGridMode("spotlight"),
@@ -707,23 +741,22 @@ test("participants must have a MatrixRTCSession to be visible", () => {
const expectedLayoutMarbles = "a-bc-b"; const expectedLayoutMarbles = "a-bc-b";
withCallViewModel( withCallViewModel(
behavior(scenarioInputMarbles, { {
remoteParticipants$: behavior(scenarioInputMarbles, {
a: [], a: [],
b: [bobParticipant], b: [bobParticipant],
c: [aliceParticipant, bobParticipant], c: [aliceParticipant, bobParticipant],
d: [aliceParticipant, daveParticipant, bobParticipant], d: [aliceParticipant, daveParticipant, bobParticipant],
e: [aliceParticipant, daveParticipant, bobSharingScreen], e: [aliceParticipant, daveParticipant, bobSharingScreen],
}), }),
behavior(scenarioInputMarbles, { rtcMembers$: behavior(scenarioInputMarbles, {
a: [localRtcMember], a: [localRtcMember],
b: [localRtcMember], b: [localRtcMember],
c: [localRtcMember, aliceRtcMember], c: [localRtcMember, aliceRtcMember],
d: [localRtcMember, aliceRtcMember, daveRtcMember], d: [localRtcMember, aliceRtcMember, daveRtcMember],
e: [localRtcMember, aliceRtcMember, daveRtcMember], e: [localRtcMember, aliceRtcMember, daveRtcMember],
}), }),
of(ConnectionState.Connected), },
new Map(),
mockMediaDevices({}),
(vm) => { (vm) => {
vm.setGridMode("grid"); vm.setGridMode("grid");
expectObservable(summarizeLayout$(vm.layout$)).toBe( expectObservable(summarizeLayout$(vm.layout$)).toBe(
@@ -760,15 +793,14 @@ test("shows participants without MatrixRTCSession when enabled in settings", ()
const expectedLayoutMarbles = "abc"; const expectedLayoutMarbles = "abc";
withCallViewModel( withCallViewModel(
behavior(scenarioInputMarbles, { {
remoteParticipants$: behavior(scenarioInputMarbles, {
a: [], a: [],
b: [aliceParticipant], b: [aliceParticipant],
c: [aliceParticipant, bobParticipant], c: [aliceParticipant, bobParticipant],
}), }),
constant([localRtcMember]), // No one else joins the MatrixRTC session rtcMembers$: constant([localRtcMember]), // No one else joins the MatrixRTC session
of(ConnectionState.Connected), },
new Map(),
mockMediaDevices({}),
(vm) => { (vm) => {
vm.setGridMode("grid"); vm.setGridMode("grid");
expectObservable(summarizeLayout$(vm.layout$)).toBe( expectObservable(summarizeLayout$(vm.layout$)).toBe(
@@ -807,16 +839,14 @@ it("should show at least one tile per MatrixRTCSession", () => {
const expectedLayoutMarbles = "abcd"; const expectedLayoutMarbles = "abcd";
withCallViewModel( withCallViewModel(
constant([]), {
behavior(scenarioInputMarbles, { rtcMembers$: behavior(scenarioInputMarbles, {
a: [localRtcMember], a: [localRtcMember],
b: [localRtcMember, aliceRtcMember], b: [localRtcMember, aliceRtcMember],
c: [localRtcMember, aliceRtcMember, daveRtcMember], c: [localRtcMember, aliceRtcMember, daveRtcMember],
d: [localRtcMember, daveRtcMember], d: [localRtcMember, daveRtcMember],
}), }),
of(ConnectionState.Connected), },
new Map(),
mockMediaDevices({}),
(vm) => { (vm) => {
vm.setGridMode("grid"); vm.setGridMode("grid");
expectObservable(summarizeLayout$(vm.layout$)).toBe( expectObservable(summarizeLayout$(vm.layout$)).toBe(
@@ -855,8 +885,8 @@ test("should disambiguate users with the same displayname", () => {
const expectedLayoutMarbles = "abcde"; const expectedLayoutMarbles = "abcde";
withCallViewModel( withCallViewModel(
constant([]), {
behavior(scenarioInputMarbles, { rtcMembers$: behavior(scenarioInputMarbles, {
a: [localRtcMember], a: [localRtcMember],
b: [localRtcMember, aliceRtcMember], b: [localRtcMember, aliceRtcMember],
c: [localRtcMember, aliceRtcMember, aliceDoppelgangerRtcMember], c: [localRtcMember, aliceRtcMember, aliceDoppelgangerRtcMember],
@@ -868,9 +898,7 @@ test("should disambiguate users with the same displayname", () => {
], ],
e: [localRtcMember, aliceDoppelgangerRtcMember, bobRtcMember], e: [localRtcMember, aliceDoppelgangerRtcMember, bobRtcMember],
}), }),
of(ConnectionState.Connected), },
new Map(),
mockMediaDevices({}),
(vm) => { (vm) => {
expectObservable(vm.memberDisplaynames$).toBe(expectedLayoutMarbles, { expectObservable(vm.memberDisplaynames$).toBe(expectedLayoutMarbles, {
// Carol has no displayname - So userId is used. // Carol has no displayname - So userId is used.
@@ -910,14 +938,12 @@ test("should disambiguate users with invisible characters", () => {
const expectedLayoutMarbles = "ab"; const expectedLayoutMarbles = "ab";
withCallViewModel( withCallViewModel(
constant([]), {
behavior(scenarioInputMarbles, { rtcMembers$: behavior(scenarioInputMarbles, {
a: [localRtcMember], a: [localRtcMember],
b: [localRtcMember, bobRtcMember, bobZeroWidthSpaceRtcMember], b: [localRtcMember, bobRtcMember, bobZeroWidthSpaceRtcMember],
}), }),
of(ConnectionState.Connected), },
new Map(),
mockMediaDevices({}),
(vm) => { (vm) => {
expectObservable(vm.memberDisplaynames$).toBe(expectedLayoutMarbles, { expectObservable(vm.memberDisplaynames$).toBe(expectedLayoutMarbles, {
// Carol has no displayname - So userId is used. // Carol has no displayname - So userId is used.
@@ -943,14 +969,12 @@ test("should strip RTL characters from displayname", () => {
const expectedLayoutMarbles = "ab"; const expectedLayoutMarbles = "ab";
withCallViewModel( withCallViewModel(
constant([]), {
behavior(scenarioInputMarbles, { rtcMembers$: behavior(scenarioInputMarbles, {
a: [localRtcMember], a: [localRtcMember],
b: [localRtcMember, daveRtcMember, daveRTLRtcMember], b: [localRtcMember, daveRtcMember, daveRTLRtcMember],
}), }),
of(ConnectionState.Connected), },
new Map(),
mockMediaDevices({}),
(vm) => { (vm) => {
expectObservable(vm.memberDisplaynames$).toBe(expectedLayoutMarbles, { expectObservable(vm.memberDisplaynames$).toBe(expectedLayoutMarbles, {
// Carol has no displayname - So userId is used. // Carol has no displayname - So userId is used.
@@ -970,16 +994,15 @@ test("should strip RTL characters from displayname", () => {
}); });
it("should rank raised hands above video feeds and below speakers and presenters", () => { it("should rank raised hands above video feeds and below speakers and presenters", () => {
withTestScheduler(({ schedule, expectObservable, behavior }) => { withTestScheduler(({ schedule, expectObservable }) => {
// There should always be one tile for each MatrixRTCSession // There should always be one tile for each MatrixRTCSession
const expectedLayoutMarbles = "ab"; const expectedLayoutMarbles = "ab";
withCallViewModel( withCallViewModel(
constant([aliceParticipant, bobParticipant]), {
constant([localRtcMember, aliceRtcMember, bobRtcMember]), remoteParticipants$: constant([aliceParticipant, bobParticipant]),
of(ConnectionState.Connected), rtcMembers$: constant([localRtcMember, aliceRtcMember, bobRtcMember]),
new Map(), },
mockMediaDevices({}),
(vm, _rtcSession, { raisedHands$ }) => { (vm, _rtcSession, { raisedHands$ }) => {
schedule("ab", { schedule("ab", {
a: () => { a: () => {
@@ -1072,11 +1095,7 @@ test("allOthersLeft$ emits only when someone joined and then all others left", (
withTestScheduler(({ hot, expectObservable, scope }) => { withTestScheduler(({ hot, expectObservable, scope }) => {
// Test scenario 1: No one ever joins - should only emit initial false and never emit again // Test scenario 1: No one ever joins - should only emit initial false and never emit again
withCallViewModel( withCallViewModel(
scope.behavior(nooneEverThere$(hot), []), { remoteParticipants$: scope.behavior(nooneEverThere$(hot), []) },
constant([localRtcMember]),
of(ConnectionState.Connected),
new Map(),
mockMediaDevices({}),
(vm) => { (vm) => {
expectObservable(vm.allOthersLeft$).toBe("n------", { n: false }); expectObservable(vm.allOthersLeft$).toBe("n------", { n: false });
}, },
@@ -1087,11 +1106,10 @@ test("allOthersLeft$ emits only when someone joined and then all others left", (
test("allOthersLeft$ emits true when someone joined and then all others left", () => { test("allOthersLeft$ emits true when someone joined and then all others left", () => {
withTestScheduler(({ hot, expectObservable, scope }) => { withTestScheduler(({ hot, expectObservable, scope }) => {
withCallViewModel( withCallViewModel(
scope.behavior(participantJoinLeave$(hot), []), {
scope.behavior(rtcMemberJoinLeave$(hot), []), remoteParticipants$: scope.behavior(participantJoinLeave$(hot), []),
of(ConnectionState.Connected), rtcMembers$: scope.behavior(rtcMemberJoinLeave$(hot), []),
new Map(), },
mockMediaDevices({}),
(vm) => { (vm) => {
expectObservable(vm.allOthersLeft$).toBe( expectObservable(vm.allOthersLeft$).toBe(
"n-----u", // false initially, then at frame 6: true then false emissions in same frame "n-----u", // false initially, then at frame 6: true then false emissions in same frame
@@ -1105,11 +1123,10 @@ test("allOthersLeft$ emits true when someone joined and then all others left", (
test("autoLeaveWhenOthersLeft$ emits only when autoLeaveWhenOthersLeft option is enabled", () => { test("autoLeaveWhenOthersLeft$ emits only when autoLeaveWhenOthersLeft option is enabled", () => {
withTestScheduler(({ hot, expectObservable, scope }) => { withTestScheduler(({ hot, expectObservable, scope }) => {
withCallViewModel( withCallViewModel(
scope.behavior(participantJoinLeave$(hot), []), {
scope.behavior(rtcMemberJoinLeave$(hot), []), remoteParticipants$: scope.behavior(participantJoinLeave$(hot), []),
of(ConnectionState.Connected), rtcMembers$: scope.behavior(rtcMemberJoinLeave$(hot), []),
new Map(), },
mockMediaDevices({}),
(vm) => { (vm) => {
expectObservable(vm.autoLeaveWhenOthersLeft$).toBe( expectObservable(vm.autoLeaveWhenOthersLeft$).toBe(
"------e", // false initially, then at frame 6: true then false emissions in same frame "------e", // false initially, then at frame 6: true then false emissions in same frame
@@ -1127,11 +1144,10 @@ test("autoLeaveWhenOthersLeft$ emits only when autoLeaveWhenOthersLeft option is
test("autoLeaveWhenOthersLeft$ never emits autoLeaveWhenOthersLeft option is enabled but no-one is there", () => { test("autoLeaveWhenOthersLeft$ never emits autoLeaveWhenOthersLeft option is enabled but no-one is there", () => {
withTestScheduler(({ hot, expectObservable, scope }) => { withTestScheduler(({ hot, expectObservable, scope }) => {
withCallViewModel( withCallViewModel(
scope.behavior(nooneEverThere$(hot), []), {
scope.behavior(nooneEverThere$(hot), []), remoteParticipants$: scope.behavior(nooneEverThere$(hot), []),
of(ConnectionState.Connected), rtcMembers$: scope.behavior(nooneEverThere$(hot), []),
new Map(), },
mockMediaDevices({}),
(vm) => { (vm) => {
expectObservable(vm.autoLeaveWhenOthersLeft$).toBe("-------"); expectObservable(vm.autoLeaveWhenOthersLeft$).toBe("-------");
}, },
@@ -1146,11 +1162,10 @@ test("autoLeaveWhenOthersLeft$ never emits autoLeaveWhenOthersLeft option is ena
test("autoLeaveWhenOthersLeft$ doesn't emit when autoLeaveWhenOthersLeft option is disabled and all others left", () => { test("autoLeaveWhenOthersLeft$ doesn't emit when autoLeaveWhenOthersLeft option is disabled and all others left", () => {
withTestScheduler(({ hot, expectObservable, scope }) => { withTestScheduler(({ hot, expectObservable, scope }) => {
withCallViewModel( withCallViewModel(
scope.behavior(participantJoinLeave$(hot), []), {
scope.behavior(rtcMemberJoinLeave$(hot), []), remoteParticipants$: scope.behavior(participantJoinLeave$(hot), []),
of(ConnectionState.Connected), rtcMembers$: scope.behavior(rtcMemberJoinLeave$(hot), []),
new Map(), },
mockMediaDevices({}),
(vm) => { (vm) => {
expectObservable(vm.autoLeaveWhenOthersLeft$).toBe("-------"); expectObservable(vm.autoLeaveWhenOthersLeft$).toBe("-------");
}, },
@@ -1165,7 +1180,8 @@ test("autoLeaveWhenOthersLeft$ doesn't emit when autoLeaveWhenOthersLeft option
test("autoLeaveWhenOthersLeft$ doesn't emits when autoLeaveWhenOthersLeft option is enabled and all others left", () => { test("autoLeaveWhenOthersLeft$ doesn't emits when autoLeaveWhenOthersLeft option is enabled and all others left", () => {
withTestScheduler(({ hot, expectObservable, scope }) => { withTestScheduler(({ hot, expectObservable, scope }) => {
withCallViewModel( withCallViewModel(
scope.behavior( {
remoteParticipants$: scope.behavior(
hot("a-b-c-d", { hot("a-b-c-d", {
a: [], // Alone a: [], // Alone
b: [aliceParticipant], // Alice joins b: [aliceParticipant], // Alice joins
@@ -1174,7 +1190,7 @@ test("autoLeaveWhenOthersLeft$ doesn't emits when autoLeaveWhenOthersLeft option
}), }),
[], //Alice leaves [], //Alice leaves
), ),
scope.behavior( rtcMembers$: scope.behavior(
hot("a-b-c-d", { hot("a-b-c-d", {
a: [localRtcMember], // Start empty a: [localRtcMember], // Start empty
b: [localRtcMember, aliceRtcMember], // Alice joins b: [localRtcMember, aliceRtcMember], // Alice joins
@@ -1183,9 +1199,7 @@ test("autoLeaveWhenOthersLeft$ doesn't emits when autoLeaveWhenOthersLeft option
}), }),
[], [],
), ),
of(ConnectionState.Connected), },
new Map(),
mockMediaDevices({}),
(vm) => { (vm) => {
expectObservable(vm.autoLeaveWhenOthersLeft$).toBe("------e", { expectObservable(vm.autoLeaveWhenOthersLeft$).toBe("------e", {
e: undefined, e: undefined,
@@ -1219,13 +1233,7 @@ test("audio output changes when toggling earpiece mode", () => {
const expectedEarpieceModeMarbles = "n-yn"; const expectedEarpieceModeMarbles = "n-yn";
const expectedTargetStateMarbles = " sese"; const expectedTargetStateMarbles = " sese";
withCallViewModel( withCallViewModel({ mediaDevices: devices }, (vm) => {
constant([]),
constant([localRtcMember]),
of(ConnectionState.Connected),
new Map(),
devices,
(vm) => {
schedule(toggleInputMarbles, { schedule(toggleInputMarbles, {
a: () => getValue(vm.audioOutputSwitcher$)?.switch(), a: () => getValue(vm.audioOutputSwitcher$)?.switch(),
}); });
@@ -1234,12 +1242,9 @@ test("audio output changes when toggling earpiece mode", () => {
yesNo, yesNo,
); );
expectObservable( expectObservable(
vm.audioOutputSwitcher$.pipe( vm.audioOutputSwitcher$.pipe(map((switcher) => switcher?.targetOutput)),
map((switcher) => switcher?.targetOutput),
),
).toBe(expectedTargetStateMarbles, { s: "speaker", e: "earpiece" }); ).toBe(expectedTargetStateMarbles, { s: "speaker", e: "earpiece" });
}, });
);
}); });
}); });
@@ -1276,13 +1281,7 @@ test("media tracks are paused while reconnecting to MatrixRTC", () => {
const expectedReconnectingMarbles = "nyn"; const expectedReconnectingMarbles = "nyn";
const expectedTrackRunningMarbles = "yny"; const expectedTrackRunningMarbles = "yny";
withCallViewModel( withCallViewModel({}, (vm, rtcSession) => {
constant([]),
constant([localRtcMember]),
of(ConnectionState.Connected),
new Map(),
mockMediaDevices({}),
(vm, rtcSession) => {
schedule(connectedMarbles, { schedule(connectedMarbles, {
y: () => { y: () => {
rtcSession.probablyLeft = false; rtcSession.probablyLeft = false;
@@ -1295,11 +1294,7 @@ test("media tracks are paused while reconnecting to MatrixRTC", () => {
expectedReconnectingMarbles, expectedReconnectingMarbles,
yesNo, yesNo,
); );
expectObservable(trackRunning$).toBe( expectObservable(trackRunning$).toBe(expectedTrackRunningMarbles, yesNo);
expectedTrackRunningMarbles, });
yesNo,
);
},
);
}); });
}); });