Skip to content

Commit

Permalink
Add test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewFerr committed Jun 21, 2024
1 parent c6f5cee commit 3f7aec7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions spec/unit/matrixrtc/MatrixRTCSession.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,42 @@ describe("MatrixRTCSession", () => {
jest.useRealTimers();
});

describe("non-legacy calls", () => {
const activeFocusConfig = { type: "livekit", livekit_service_url: "https://active.url" };
const activeFocus = { type: "livekit", focus_selection: "oldest_membership" };

function testJoin(useOwnedStateEvents: boolean): void {
if (useOwnedStateEvents) {
mockRoom.getVersion = jest.fn().mockReturnValue("org.matrix.msc3779.default");
}

jest.useFakeTimers();
sess!.joinRoomSession([activeFocusConfig], activeFocus, { useLegacyMemberEvents: false });
expect(client.sendStateEvent).toHaveBeenCalledWith(
mockRoom!.roomId,
EventType.GroupCallMemberPrefix,
{
application: "m.call",
scope: "m.room",
call_id: "",
device_id: "AAAAAAA",
foci_preferred: [activeFocusConfig],
focus_active: activeFocus,
} satisfies SessionMembershipData,
`${!useOwnedStateEvents ? "_" : ""}@alice:example.org_AAAAAAA`,
);
jest.useRealTimers();
}

it("sends a membership event with session payload when joining a non-legacy call", () => {
testJoin(false);
});

it("does not prefix the state key with _ for rooms that support user-owned state events", () => {
testJoin(true);
});
});

it("does nothing if join called when already joined", () => {
sess!.joinRoomSession([mockFocus], mockFocus);

Expand Down
1 change: 1 addition & 0 deletions spec/unit/matrixrtc/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export function makeMockRoom(membershipData: MembershipData, localAge: number |
getLiveTimeline: jest.fn().mockReturnValue({
getState: jest.fn().mockReturnValue(roomState),
}),
getVersion: jest.fn().mockReturnValue("default"),
} as unknown as Room;
}

Expand Down

0 comments on commit 3f7aec7

Please sign in to comment.