Handle local events for voice broadcasts (#9561)
This commit is contained in:
parent
848adfdc10
commit
7fbdd8bb5d
4 changed files with 51 additions and 8 deletions
|
@ -22,9 +22,11 @@ import { mkVoiceBroadcastChunkEvent } from "./test-utils";
|
|||
describe("VoiceBroadcastChunkEvents", () => {
|
||||
const userId = "@user:example.com";
|
||||
const roomId = "!room:example.com";
|
||||
const txnId = "txn-id";
|
||||
let eventSeq1Time1: MatrixEvent;
|
||||
let eventSeq2Time4: MatrixEvent;
|
||||
let eventSeq3Time2: MatrixEvent;
|
||||
let eventSeq3Time2T: MatrixEvent;
|
||||
let eventSeq4Time1: MatrixEvent;
|
||||
let eventSeqUTime3: MatrixEvent;
|
||||
let eventSeq2Time4Dup: MatrixEvent;
|
||||
|
@ -36,6 +38,9 @@ describe("VoiceBroadcastChunkEvents", () => {
|
|||
eventSeq2Time4Dup = mkVoiceBroadcastChunkEvent(userId, roomId, 3141, 2, 4);
|
||||
jest.spyOn(eventSeq2Time4Dup, "getId").mockReturnValue(eventSeq2Time4.getId());
|
||||
eventSeq3Time2 = mkVoiceBroadcastChunkEvent(userId, roomId, 42, 3, 2);
|
||||
eventSeq3Time2.setTxnId(txnId);
|
||||
eventSeq3Time2T = mkVoiceBroadcastChunkEvent(userId, roomId, 42, 3, 2);
|
||||
eventSeq3Time2T.setTxnId(txnId);
|
||||
eventSeq4Time1 = mkVoiceBroadcastChunkEvent(userId, roomId, 69, 4, 1);
|
||||
eventSeqUTime3 = mkVoiceBroadcastChunkEvent(userId, roomId, 314, undefined, 3);
|
||||
chunkEvents = new VoiceBroadcastChunkEvents();
|
||||
|
@ -96,6 +101,21 @@ describe("VoiceBroadcastChunkEvents", () => {
|
|||
it("findByTime(entire duration) should return the last chunk", () => {
|
||||
expect(chunkEvents.findByTime(7 + 3141 + 42 + 69)).toBe(eventSeq4Time1);
|
||||
});
|
||||
|
||||
describe("and adding an event with a known transaction Id", () => {
|
||||
beforeEach(() => {
|
||||
chunkEvents.addEvent(eventSeq3Time2T);
|
||||
});
|
||||
|
||||
it("should replace the previous event", () => {
|
||||
expect(chunkEvents.getEvents()).toEqual([
|
||||
eventSeq1Time1,
|
||||
eventSeq2Time4Dup,
|
||||
eventSeq3Time2T,
|
||||
eventSeq4Time1,
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("when adding events where at least one does not have a sequence", () => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue