add test to check if publisher is properly destroyed

This commit is contained in:
Timo K
2026-01-16 14:41:11 +01:00
parent a99a413b88
commit 3f8b3ba3f1
2 changed files with 35 additions and 4 deletions
@@ -209,10 +209,35 @@ describe("Publisher", () => {
});
it("should unsetHandler and stop tracks on destroy", async () => {
// setup all spies
const unsetVideoSpy = vi.spyOn(
(
publisher as unknown as {
muteStates: { video: { unsetHandler: () => void } };
}
).muteStates.video,
"unsetHandler",
);
const unsetAudioSpy = vi.spyOn(
(
publisher as unknown as {
muteStates: { audio: { unsetHandler: () => void } };
}
).muteStates.audio,
"unsetHandler",
);
const scopeEndSpy = vi.spyOn(
(publisher as unknown as { scope: { end: () => void } }).scope,
"end",
);
const stopTracksSpy = vi.spyOn(publisher, "stopTracks");
// destroy publisher
await publisher.destroy();
expect(publisher.stopTracks).toHaveBeenCalled();
expect( this.muteStates.audio.unsetHandler();
this.muteStates.video.unsetHandler();).toHaveBeenCalled();
expect(stopTracksSpy).toHaveBeenCalledOnce();
expect(unsetVideoSpy).toHaveBeenCalledOnce();
expect(unsetAudioSpy).toHaveBeenCalledOnce();
expect(scopeEndSpy).toHaveBeenCalled();
});
it("Should minimize permission request by querying create at once", async () => {