Handle local events for voice broadcasts (#9561)

This commit is contained in:
Michael Weimann 2022-11-09 12:17:54 +01:00 committed by GitHub
parent 848adfdc10
commit 7fbdd8bb5d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 8 deletions

View file

@ -49,6 +49,7 @@ describe("VoiceBroadcastPlayback", () => {
let onStateChanged: (state: VoiceBroadcastPlaybackState) => void;
let chunk1Event: MatrixEvent;
let chunk2Event: MatrixEvent;
let chunk2BEvent: MatrixEvent;
let chunk3Event: MatrixEvent;
const chunk1Length = 2300;
const chunk2Length = 4200;
@ -135,6 +136,9 @@ describe("VoiceBroadcastPlayback", () => {
chunk1Event = mkVoiceBroadcastChunkEvent(userId, roomId, chunk1Length, 1);
chunk2Event = mkVoiceBroadcastChunkEvent(userId, roomId, chunk2Length, 2);
chunk2Event.setTxnId("tx-id-1");
chunk2BEvent = mkVoiceBroadcastChunkEvent(userId, roomId, chunk2Length, 2);
chunk2BEvent.setTxnId("tx-id-1");
chunk3Event = mkVoiceBroadcastChunkEvent(userId, roomId, chunk3Length, 3);
chunk1Helper = mkChunkHelper(chunk1Data);
@ -240,6 +244,21 @@ describe("VoiceBroadcastPlayback", () => {
playback = await mkPlayback();
});
it("durationSeconds should have the length of the known chunks", () => {
expect(playback.durationSeconds).toEqual(6.5);
});
describe("and an event with the same transaction Id occurs", () => {
beforeEach(() => {
// @ts-ignore
playback.chunkRelationHelper.emit(RelationsHelperEvent.Add, chunk2BEvent);
});
it("durationSeconds should not change", () => {
expect(playback.durationSeconds).toEqual(6.5);
});
});
describe("and calling start", () => {
startPlayback();