Apply prettier formatting
This commit is contained in:
parent
1cac306093
commit
526645c791
1576 changed files with 65385 additions and 62478 deletions
|
@ -50,11 +50,7 @@ describe("VoiceBroadcastChunkEvents", () => {
|
|||
beforeEach(() => {
|
||||
chunkEvents.addEvent(eventSeq2Time4);
|
||||
chunkEvents.addEvent(eventSeq1Time1);
|
||||
chunkEvents.addEvents([
|
||||
eventSeq4Time1,
|
||||
eventSeq2Time4Dup,
|
||||
eventSeq3Time2,
|
||||
]);
|
||||
chunkEvents.addEvents([eventSeq4Time1, eventSeq2Time4Dup, eventSeq3Time2]);
|
||||
});
|
||||
|
||||
it("should provide the events sort by sequence", () => {
|
||||
|
@ -122,12 +118,7 @@ describe("VoiceBroadcastChunkEvents", () => {
|
|||
beforeEach(() => {
|
||||
chunkEvents.addEvent(eventSeq2Time4);
|
||||
chunkEvents.addEvent(eventSeq1Time1);
|
||||
chunkEvents.addEvents([
|
||||
eventSeq4Time1,
|
||||
eventSeqUTime3,
|
||||
eventSeq2Time4Dup,
|
||||
eventSeq3Time2,
|
||||
]);
|
||||
chunkEvents.addEvents([eventSeq4Time1, eventSeqUTime3, eventSeq2Time4Dup, eventSeq3Time2]);
|
||||
});
|
||||
|
||||
it("should provide the events sort by timestamp without duplicates", () => {
|
||||
|
|
|
@ -32,11 +32,9 @@ describe("findRoomLiveVoiceBroadcastFromUserAndDevice", () => {
|
|||
|
||||
const itShouldReturnNull = () => {
|
||||
it("should return null", () => {
|
||||
expect(findRoomLiveVoiceBroadcastFromUserAndDevice(
|
||||
room,
|
||||
client.getUserId(),
|
||||
client.getDeviceId(),
|
||||
)).toBeNull();
|
||||
expect(
|
||||
findRoomLiveVoiceBroadcastFromUserAndDevice(room, client.getUserId(), client.getDeviceId()),
|
||||
).toBeNull();
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -117,11 +115,9 @@ describe("findRoomLiveVoiceBroadcastFromUserAndDevice", () => {
|
|||
client.getUserId(),
|
||||
);
|
||||
|
||||
expect(findRoomLiveVoiceBroadcastFromUserAndDevice(
|
||||
room,
|
||||
client.getUserId(),
|
||||
client.getDeviceId(),
|
||||
)).toBe(event);
|
||||
expect(findRoomLiveVoiceBroadcastFromUserAndDevice(room, client.getUserId(), client.getDeviceId())).toBe(
|
||||
event,
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -31,16 +31,8 @@ describe("hasRoomLiveVoiceBroadcast", () => {
|
|||
let room: Room;
|
||||
let expectedEvent: MatrixEvent | null = null;
|
||||
|
||||
const addVoiceBroadcastInfoEvent = (
|
||||
state: VoiceBroadcastInfoState,
|
||||
sender: string,
|
||||
): MatrixEvent => {
|
||||
const infoEvent = mkVoiceBroadcastInfoStateEvent(
|
||||
room.roomId,
|
||||
state,
|
||||
sender,
|
||||
"ASD123",
|
||||
);
|
||||
const addVoiceBroadcastInfoEvent = (state: VoiceBroadcastInfoState, sender: string): MatrixEvent => {
|
||||
const infoEvent = mkVoiceBroadcastInfoStateEvent(room.roomId, state, sender, "ASD123");
|
||||
room.currentState.setStateEvents([infoEvent]);
|
||||
return infoEvent;
|
||||
};
|
||||
|
|
|
@ -45,13 +45,9 @@ describe("setUpVoiceBroadcastPreRecording", () => {
|
|||
|
||||
const itShouldReturnNull = () => {
|
||||
it("should return null", () => {
|
||||
expect(setUpVoiceBroadcastPreRecording(
|
||||
room,
|
||||
client,
|
||||
playbacksStore,
|
||||
recordingsStore,
|
||||
preRecordingStore,
|
||||
)).toBeNull();
|
||||
expect(
|
||||
setUpVoiceBroadcastPreRecording(room, client, playbacksStore, recordingsStore, preRecordingStore),
|
||||
).toBeNull();
|
||||
expect(checkVoiceBroadcastPreConditions).toHaveBeenCalledWith(room, client, recordingsStore);
|
||||
});
|
||||
};
|
||||
|
@ -110,9 +106,7 @@ describe("setUpVoiceBroadcastPreRecording", () => {
|
|||
describe("and there is a room member and listening to another broadcast", () => {
|
||||
beforeEach(() => {
|
||||
playbacksStore.setCurrent(playback);
|
||||
room.currentState.setStateEvents([
|
||||
mkRoomMemberJoinEvent(userId, roomId),
|
||||
]);
|
||||
room.currentState.setStateEvents([mkRoomMemberJoinEvent(userId, roomId)]);
|
||||
});
|
||||
|
||||
it("should pause the current playback and create a voice broadcast pre-recording", () => {
|
||||
|
|
|
@ -31,42 +31,12 @@ const testCases = [
|
|||
VoiceBroadcastInfoState.Started,
|
||||
true, // expected return value
|
||||
],
|
||||
[
|
||||
"@user1:example.com",
|
||||
"@user1:example.com",
|
||||
VoiceBroadcastInfoState.Paused,
|
||||
true,
|
||||
],
|
||||
[
|
||||
"@user1:example.com",
|
||||
"@user1:example.com",
|
||||
VoiceBroadcastInfoState.Resumed,
|
||||
true,
|
||||
],
|
||||
[
|
||||
"@user1:example.com",
|
||||
"@user1:example.com",
|
||||
VoiceBroadcastInfoState.Stopped,
|
||||
false,
|
||||
],
|
||||
[
|
||||
"@user2:example.com",
|
||||
"@user1:example.com",
|
||||
VoiceBroadcastInfoState.Started,
|
||||
false,
|
||||
],
|
||||
[
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
],
|
||||
[
|
||||
undefined,
|
||||
undefined,
|
||||
undefined,
|
||||
false,
|
||||
],
|
||||
["@user1:example.com", "@user1:example.com", VoiceBroadcastInfoState.Paused, true],
|
||||
["@user1:example.com", "@user1:example.com", VoiceBroadcastInfoState.Resumed, true],
|
||||
["@user1:example.com", "@user1:example.com", VoiceBroadcastInfoState.Stopped, false],
|
||||
["@user2:example.com", "@user1:example.com", VoiceBroadcastInfoState.Started, false],
|
||||
[null, null, null, false],
|
||||
[undefined, undefined, undefined, false],
|
||||
];
|
||||
|
||||
describe("shouldDisplayAsVoiceBroadcastRecordingTile", () => {
|
||||
|
@ -94,5 +64,6 @@ describe("shouldDisplayAsVoiceBroadcastRecordingTile", () => {
|
|||
it(`should return ${expected}`, () => {
|
||||
expect(shouldDisplayAsVoiceBroadcastRecordingTile(state, client, event)).toBe(expected);
|
||||
});
|
||||
});
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -125,25 +125,22 @@ describe("shouldDisplayAsVoiceBroadcastTile", () => {
|
|||
itShouldReturnTrue();
|
||||
});
|
||||
|
||||
describe.each(
|
||||
[
|
||||
VoiceBroadcastInfoState.Paused,
|
||||
VoiceBroadcastInfoState.Resumed,
|
||||
VoiceBroadcastInfoState.Stopped,
|
||||
],
|
||||
)("when a voice broadcast info event in state %s occurs", (state: VoiceBroadcastInfoState) => {
|
||||
beforeEach(() => {
|
||||
event = mkEvent({
|
||||
event: true,
|
||||
type: VoiceBroadcastInfoEventType,
|
||||
room: roomId,
|
||||
user: senderId,
|
||||
content: {
|
||||
state,
|
||||
},
|
||||
describe.each([VoiceBroadcastInfoState.Paused, VoiceBroadcastInfoState.Resumed, VoiceBroadcastInfoState.Stopped])(
|
||||
"when a voice broadcast info event in state %s occurs",
|
||||
(state: VoiceBroadcastInfoState) => {
|
||||
beforeEach(() => {
|
||||
event = mkEvent({
|
||||
event: true,
|
||||
type: VoiceBroadcastInfoEventType,
|
||||
room: roomId,
|
||||
user: senderId,
|
||||
content: {
|
||||
state,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
itShouldReturnFalse();
|
||||
});
|
||||
itShouldReturnFalse();
|
||||
},
|
||||
);
|
||||
});
|
||||
|
|
|
@ -59,18 +59,15 @@ describe("startNewVoiceBroadcastRecording", () => {
|
|||
|
||||
return null;
|
||||
});
|
||||
mocked(client.sendStateEvent).mockImplementation((
|
||||
sendRoomId: string,
|
||||
eventType: string,
|
||||
content: any,
|
||||
stateKey: string,
|
||||
): Promise<ISendEventResponse> => {
|
||||
if (sendRoomId === roomId && eventType === VoiceBroadcastInfoEventType) {
|
||||
return Promise.resolve({ event_id: infoEvent.getId()! });
|
||||
}
|
||||
mocked(client.sendStateEvent).mockImplementation(
|
||||
(sendRoomId: string, eventType: string, content: any, stateKey: string): Promise<ISendEventResponse> => {
|
||||
if (sendRoomId === roomId && eventType === VoiceBroadcastInfoEventType) {
|
||||
return Promise.resolve({ event_id: infoEvent.getId()! });
|
||||
}
|
||||
|
||||
throw new Error("Unexpected sendStateEvent call");
|
||||
});
|
||||
throw new Error("Unexpected sendStateEvent call");
|
||||
},
|
||||
);
|
||||
|
||||
infoEvent = mkVoiceBroadcastInfoStateEvent(
|
||||
roomId,
|
||||
|
@ -93,10 +90,7 @@ describe("startNewVoiceBroadcastRecording", () => {
|
|||
getCurrent: jest.fn(),
|
||||
} as unknown as VoiceBroadcastRecordingsStore;
|
||||
|
||||
mocked(VoiceBroadcastRecording).mockImplementation((
|
||||
infoEvent: MatrixEvent,
|
||||
client: MatrixClient,
|
||||
): any => {
|
||||
mocked(VoiceBroadcastRecording).mockImplementation((infoEvent: MatrixEvent, client: MatrixClient): any => {
|
||||
return {
|
||||
infoEvent,
|
||||
client,
|
||||
|
@ -124,19 +118,21 @@ describe("startNewVoiceBroadcastRecording", () => {
|
|||
});
|
||||
|
||||
it("should stop listen to the current broadcast and create a new recording", async () => {
|
||||
mocked(client.sendStateEvent).mockImplementation(async (
|
||||
_roomId: string,
|
||||
_eventType: string,
|
||||
_content: any,
|
||||
_stateKey = "",
|
||||
): Promise<ISendEventResponse> => {
|
||||
window.setTimeout(() => {
|
||||
// emit state events after resolving the promise
|
||||
room.currentState.setStateEvents([otherEvent]);
|
||||
room.currentState.setStateEvents([infoEvent]);
|
||||
}, 0);
|
||||
return { event_id: infoEvent.getId()! };
|
||||
});
|
||||
mocked(client.sendStateEvent).mockImplementation(
|
||||
async (
|
||||
_roomId: string,
|
||||
_eventType: string,
|
||||
_content: any,
|
||||
_stateKey = "",
|
||||
): Promise<ISendEventResponse> => {
|
||||
window.setTimeout(() => {
|
||||
// emit state events after resolving the promise
|
||||
room.currentState.setStateEvents([otherEvent]);
|
||||
room.currentState.setStateEvents([infoEvent]);
|
||||
}, 0);
|
||||
return { event_id: infoEvent.getId()! };
|
||||
},
|
||||
);
|
||||
const recording = await startNewVoiceBroadcastRecording(room, client, playbacksStore, recordingsStore);
|
||||
expect(recording).not.toBeNull();
|
||||
|
||||
|
@ -161,9 +157,7 @@ describe("startNewVoiceBroadcastRecording", () => {
|
|||
|
||||
describe("when there is already a current voice broadcast", () => {
|
||||
beforeEach(async () => {
|
||||
mocked(recordingsStore.getCurrent).mockReturnValue(
|
||||
new VoiceBroadcastRecording(infoEvent, client),
|
||||
);
|
||||
mocked(recordingsStore.getCurrent).mockReturnValue(new VoiceBroadcastRecording(infoEvent, client));
|
||||
|
||||
result = await startNewVoiceBroadcastRecording(room, client, playbacksStore, recordingsStore);
|
||||
});
|
||||
|
@ -203,12 +197,7 @@ describe("startNewVoiceBroadcastRecording", () => {
|
|||
describe("when there already is a live broadcast of another user", () => {
|
||||
beforeEach(async () => {
|
||||
room.currentState.setStateEvents([
|
||||
mkVoiceBroadcastInfoStateEvent(
|
||||
roomId,
|
||||
VoiceBroadcastInfoState.Resumed,
|
||||
otherUserId,
|
||||
"ASD123",
|
||||
),
|
||||
mkVoiceBroadcastInfoStateEvent(roomId, VoiceBroadcastInfoState.Resumed, otherUserId, "ASD123"),
|
||||
]);
|
||||
|
||||
result = await startNewVoiceBroadcastRecording(room, client, playbacksStore, recordingsStore);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue