End voice broadcast recording on any call (#9425)

This commit is contained in:
Michael Weimann 2022-10-16 13:35:25 +02:00 committed by GitHub
parent 81533b905f
commit 0630a9c448
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 78 additions and 4 deletions

View file

@ -41,6 +41,7 @@ import {
VoiceBroadcastRecordingEvent,
} from "../../../src/voice-broadcast";
import { mkEvent, mkStubRoom, stubClient } from "../../test-utils";
import dis from "../../../src/dispatcher/dispatcher";
jest.mock("../../../src/voice-broadcast/audio/VoiceBroadcastRecorder", () => ({
...jest.requireActual("../../../src/voice-broadcast/audio/VoiceBroadcastRecorder") as object,
@ -83,6 +84,12 @@ describe("VoiceBroadcastRecording", () => {
jest.spyOn(voiceBroadcastRecording, "removeAllListeners");
};
const itShouldBeInState = (state: VoiceBroadcastInfoState) => {
it(`should be in state stopped ${state}`, () => {
expect(voiceBroadcastRecording.getState()).toBe(state);
});
};
beforeEach(() => {
client = stubClient();
room = mkStubRoom(roomId, "Test Room", client);
@ -191,9 +198,7 @@ describe("VoiceBroadcastRecording", () => {
);
});
it("should be in state stopped", () => {
expect(voiceBroadcastRecording.getState()).toBe(VoiceBroadcastInfoState.Stopped);
});
itShouldBeInState(VoiceBroadcastInfoState.Stopped);
it("should emit a stopped state changed event", () => {
expect(onStateChanged).toHaveBeenCalledWith(VoiceBroadcastInfoState.Stopped);
@ -209,6 +214,16 @@ describe("VoiceBroadcastRecording", () => {
expect(voiceBroadcastRecorder.start).toHaveBeenCalled();
});
describe("and receiving a call action", () => {
beforeEach(() => {
dis.dispatch({
action: "call_state",
}, true);
});
itShouldBeInState(VoiceBroadcastInfoState.Stopped);
});
describe("and a chunk has been recorded", () => {
beforeEach(async () => {
await onChunkRecorded({