fix missing mock for test

This commit is contained in:
Valere
2025-12-05 18:28:36 +01:00
parent 0a09b8a676
commit 53542ca957
2 changed files with 17 additions and 8 deletions

View File

@@ -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);
}); });
}); });

View File

@@ -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?