mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-05 19:59:20 +00:00
fix missing mock for test
This commit is contained in:
@@ -98,14 +98,19 @@ describe("Publisher", () => {
|
|||||||
|
|
||||||
(
|
(
|
||||||
connection.livekitRoom.localParticipant.createTracks as Mock
|
connection.livekitRoom.localParticipant.createTracks as Mock
|
||||||
).mockResolvedValue([{}, {}]);
|
).mockResolvedValue([
|
||||||
|
{
|
||||||
|
kind: "audio",
|
||||||
|
mute: vi.fn(),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
|
||||||
await expect(publisher.createAndSetupTracks()).resolves.not.toThrow();
|
await expect(publisher.createAndSetupTracks()).resolves.not.toThrow();
|
||||||
expect(
|
expect(
|
||||||
connection.livekitRoom.localParticipant.createTracks,
|
connection.livekitRoom.localParticipant.createTracks,
|
||||||
).toHaveBeenCalledOnce();
|
).toHaveBeenCalledOnce();
|
||||||
|
|
||||||
// failiour due to localParticipant.publishTrack
|
// failure due to localParticipant.publishTrack
|
||||||
(
|
(
|
||||||
connection.livekitRoom.localParticipant.publishTrack as Mock
|
connection.livekitRoom.localParticipant.publishTrack as Mock
|
||||||
).mockRejectedValue(Error("testError"));
|
).mockRejectedValue(Error("testError"));
|
||||||
@@ -114,7 +119,7 @@ describe("Publisher", () => {
|
|||||||
new FailToStartLivekitConnection("testError"),
|
new FailToStartLivekitConnection("testError"),
|
||||||
);
|
);
|
||||||
|
|
||||||
// does not try other conenction after the first one failed
|
// does not try other connection after the first one failed
|
||||||
expect(
|
expect(
|
||||||
connection.livekitRoom.localParticipant.publishTrack,
|
connection.livekitRoom.localParticipant.publishTrack,
|
||||||
).toHaveBeenCalledTimes(1);
|
).toHaveBeenCalledTimes(1);
|
||||||
@@ -145,7 +150,7 @@ describe("Publisher", () => {
|
|||||||
|
|
||||||
expect(
|
expect(
|
||||||
connection.livekitRoom.localParticipant.publishTrack,
|
connection.livekitRoom.localParticipant.publishTrack,
|
||||||
).toHaveBeenCalledTimes(3);
|
).toHaveBeenCalledTimes(2);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -191,10 +191,14 @@ export class Publisher {
|
|||||||
// or only use the low level create/publish APIs and have our own pending publication protection.
|
// or only use the low level create/publish APIs and have our own pending publication protection.
|
||||||
// Maybe we could change the livekit api to pre-load tracks without publishing them yet?
|
// Maybe we could change the livekit api to pre-load tracks without publishing them yet?
|
||||||
// Are we sure this is needed at all? What are the gains?
|
// Are we sure this is needed at all? What are the gains?
|
||||||
const isEnabled =
|
let isEnabled: boolean;
|
||||||
track.kind === Track.Kind.Audio
|
if (track.kind === Track.Kind.Audio) {
|
||||||
? this.muteStates.audio.enabled$.value
|
isEnabled = this.muteStates.audio.enabled$.value;
|
||||||
: this.muteStates.video.enabled$.value;
|
} else if (track.kind === Track.Kind.Video) {
|
||||||
|
isEnabled = this.muteStates.video.enabled$.value;
|
||||||
|
} else {
|
||||||
|
throw new Error("Unsupported track kind " + track.kind);
|
||||||
|
}
|
||||||
|
|
||||||
if (!isEnabled) {
|
if (!isEnabled) {
|
||||||
// TODO should we also drop it?
|
// TODO should we also drop it?
|
||||||
|
|||||||
Reference in New Issue
Block a user