1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-30 02:21:17 +03:00

Add voice broadcast ended message (#9728)

This commit is contained in:
Michael Weimann
2022-12-12 16:03:56 +01:00
committed by GitHub
parent 9de5654353
commit 57e1822add
11 changed files with 286 additions and 23 deletions

View File

@ -14,22 +14,30 @@ limitations under the License.
import { EventType, MatrixClient, MatrixEvent, MsgType } from "matrix-js-sdk/src/matrix";
import { JSONEventFactory, pickFactory } from "../../src/events/EventTileFactory";
import { VoiceBroadcastChunkEventType } from "../../src/voice-broadcast";
import { VoiceBroadcastChunkEventType, VoiceBroadcastInfoState } from "../../src/voice-broadcast";
import { createTestClient, mkEvent } from "../test-utils";
import { mkVoiceBroadcastInfoStateEvent } from "../voice-broadcast/utils/test-utils";
const roomId = "!room:example.com";
describe("pickFactory", () => {
let voiceBroadcastStoppedEvent: MatrixEvent;
let voiceBroadcastChunkEvent: MatrixEvent;
let audioMessageEvent: MatrixEvent;
let client: MatrixClient;
beforeAll(() => {
client = createTestClient();
voiceBroadcastStoppedEvent = mkVoiceBroadcastInfoStateEvent(
"!room:example.com",
VoiceBroadcastInfoState.Stopped,
client.getUserId()!,
client.deviceId!,
);
voiceBroadcastChunkEvent = mkEvent({
event: true,
type: EventType.RoomMessage,
user: client.getUserId(),
user: client.getUserId()!,
room: roomId,
content: {
msgtype: MsgType.Audio,
@ -39,7 +47,7 @@ describe("pickFactory", () => {
audioMessageEvent = mkEvent({
event: true,
type: EventType.RoomMessage,
user: client.getUserId(),
user: client.getUserId()!,
room: roomId,
content: {
msgtype: MsgType.Audio,
@ -52,7 +60,7 @@ describe("pickFactory", () => {
type: EventType.RoomPowerLevels,
state_key: "",
content: {},
sender: client.getUserId(),
sender: client.getUserId()!,
room_id: roomId,
});
expect(pickFactory(event, client, true)).toBe(JSONEventFactory);
@ -63,6 +71,10 @@ describe("pickFactory", () => {
expect(pickFactory(voiceBroadcastChunkEvent, client, true)).toBeInstanceOf(Function);
});
it("should return a Function for a voice broadcast stopped event", () => {
expect(pickFactory(voiceBroadcastStoppedEvent, client, true)).toBeInstanceOf(Function);
});
it("should return a function for an audio message event", () => {
expect(pickFactory(audioMessageEvent, client, true)).toBeInstanceOf(Function);
});
@ -73,6 +85,10 @@ describe("pickFactory", () => {
expect(pickFactory(voiceBroadcastChunkEvent, client, false)).toBeUndefined();
});
it("should return a Function for a voice broadcast stopped event", () => {
expect(pickFactory(voiceBroadcastStoppedEvent, client, true)).toBeInstanceOf(Function);
});
it("should return a function for an audio message event", () => {
expect(pickFactory(audioMessageEvent, client, false)).toBeInstanceOf(Function);
});