Stop voice broadcast on delete (#9629)

This commit is contained in:
Michael Weimann 2022-11-28 18:45:50 +01:00 committed by GitHub
parent d6ea92f735
commit 3c7781a561
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 0 deletions

View file

@ -126,6 +126,7 @@ describe("VoiceBroadcastPlayback", () => {
const mkPlayback = async () => {
const playback = new VoiceBroadcastPlayback(infoEvent, client);
jest.spyOn(playback, "removeAllListeners");
jest.spyOn(playback, "destroy");
playback.on(VoiceBroadcastPlaybackEvent.StateChanged, onStateChanged);
await flushPromises();
return playback;
@ -273,6 +274,7 @@ describe("VoiceBroadcastPlayback", () => {
startPlayback();
it("should play the last chunk", () => {
expect(playback.getState()).toBe(VoiceBroadcastPlaybackState.Playing);
// assert that the last chunk is played first
expect(chunk2Playback.play).toHaveBeenCalled();
expect(chunk1Playback.play).not.toHaveBeenCalled();
@ -299,6 +301,17 @@ describe("VoiceBroadcastPlayback", () => {
});
});
});
describe("and the info event is deleted", () => {
beforeEach(() => {
infoEvent.makeRedacted(new MatrixEvent({}));
});
it("should stop and destroy the playback", () => {
expect(playback.getState()).toBe(VoiceBroadcastPlaybackState.Stopped);
expect(playback.destroy).toHaveBeenCalled();
});
});
});
});