Skip to content

Commit 3c04d2b

Browse files
committed
remove all legacy call related code and adjust tests.
We actually had a bit of tests just for legacy and not for session events. All those tests got ported over so we do not remove any tests.
1 parent 3ae2542 commit 3c04d2b

8 files changed

Lines changed: 206 additions & 612 deletions

File tree

spec/unit/matrixrtc/CallMembership.spec.ts

Lines changed: 5 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ limitations under the License.
1515
*/
1616

1717
import { MatrixEvent } from "../../../src";
18-
import { CallMembership, CallMembershipDataLegacy, SessionMembershipData } from "../../../src/matrixrtc/CallMembership";
18+
import { CallMembership, DEFAULT_EXPIRE_DURATION, SessionMembershipData } from "../../../src/matrixrtc/CallMembership";
19+
import { membershipTemplate } from "./mocks";
1920

2021
function makeMockEvent(originTs = 0): MatrixEvent {
2122
return {
@@ -25,90 +26,6 @@ function makeMockEvent(originTs = 0): MatrixEvent {
2526
}
2627

2728
describe("CallMembership", () => {
28-
describe("CallMembershipDataLegacy", () => {
29-
const membershipTemplate: CallMembershipDataLegacy = {
30-
call_id: "",
31-
scope: "m.room",
32-
application: "m.call",
33-
device_id: "AAAAAAA",
34-
expires: 5000,
35-
membershipID: "bloop",
36-
foci_active: [{ type: "livekit" }],
37-
};
38-
it("rejects membership with no expiry and no expires_ts", () => {
39-
expect(() => {
40-
new CallMembership(
41-
makeMockEvent(),
42-
Object.assign({}, membershipTemplate, { expires: undefined, expires_ts: undefined }),
43-
);
44-
}).toThrow();
45-
});
46-
47-
it("rejects membership with no device_id", () => {
48-
expect(() => {
49-
new CallMembership(makeMockEvent(), Object.assign({}, membershipTemplate, { device_id: undefined }));
50-
}).toThrow();
51-
});
52-
53-
it("rejects membership with no call_id", () => {
54-
expect(() => {
55-
new CallMembership(makeMockEvent(), Object.assign({}, membershipTemplate, { call_id: undefined }));
56-
}).toThrow();
57-
});
58-
59-
it("allow membership with no scope", () => {
60-
expect(() => {
61-
new CallMembership(makeMockEvent(), Object.assign({}, membershipTemplate, { scope: undefined }));
62-
}).not.toThrow();
63-
});
64-
it("rejects with malformatted expires_ts", () => {
65-
expect(() => {
66-
new CallMembership(makeMockEvent(), Object.assign({}, membershipTemplate, { expires_ts: "string" }));
67-
}).toThrow();
68-
});
69-
it("rejects with malformatted expires", () => {
70-
expect(() => {
71-
new CallMembership(makeMockEvent(), Object.assign({}, membershipTemplate, { expires: "string" }));
72-
}).toThrow();
73-
});
74-
75-
it("uses event timestamp if no created_ts", () => {
76-
const membership = new CallMembership(makeMockEvent(12345), membershipTemplate);
77-
expect(membership.createdTs()).toEqual(12345);
78-
});
79-
80-
it("uses created_ts if present", () => {
81-
const membership = new CallMembership(
82-
makeMockEvent(12345),
83-
Object.assign({}, membershipTemplate, { created_ts: 67890 }),
84-
);
85-
expect(membership.createdTs()).toEqual(67890);
86-
});
87-
88-
it("computes absolute expiry time based on expires", () => {
89-
const membership = new CallMembership(makeMockEvent(1000), membershipTemplate);
90-
expect(membership.getAbsoluteExpiry()).toEqual(5000 + 1000);
91-
});
92-
93-
it("computes absolute expiry time based on expires_ts", () => {
94-
const membership = new CallMembership(
95-
makeMockEvent(1000),
96-
Object.assign({}, membershipTemplate, { expires_ts: 6000 }),
97-
);
98-
expect(membership.getAbsoluteExpiry()).toEqual(5000 + 1000);
99-
});
100-
101-
it("returns preferred foci", () => {
102-
const fakeEvent = makeMockEvent();
103-
const mockFocus = { type: "this_is_a_mock_focus" };
104-
const membership = new CallMembership(
105-
fakeEvent,
106-
Object.assign({}, membershipTemplate, { foci_active: [mockFocus] }),
107-
);
108-
expect(membership.getPreferredFoci()).toEqual([mockFocus]);
109-
});
110-
});
111-
11229
describe("SessionMembershipData", () => {
11330
const membershipTemplate: SessionMembershipData = {
11431
call_id: "",
@@ -171,15 +88,6 @@ describe("CallMembership", () => {
17188
describe("expiry calculation", () => {
17289
let fakeEvent: MatrixEvent;
17390
let membership: CallMembership;
174-
const membershipTemplate: CallMembershipDataLegacy = {
175-
call_id: "",
176-
scope: "m.room",
177-
application: "m.call",
178-
device_id: "AAAAAAA",
179-
expires: 5000,
180-
membershipID: "bloop",
181-
foci_active: [{ type: "livekit" }],
182-
};
18391

18492
beforeEach(() => {
18593
// server origin timestamp for this event is 1000
@@ -202,15 +110,15 @@ describe("CallMembership", () => {
202110
fakeEvent.getLocalAge = jest.fn().mockReturnValue(0);
203111

204112
// for sanity's sake, make sure the server-relative expiry time is what we expect
205-
expect(membership.getAbsoluteExpiry()).toEqual(6000);
113+
expect(membership.getAbsoluteExpiry()).toEqual(DEFAULT_EXPIRE_DURATION + 1000);
206114
// therefore the expiry time converted to our clock should be 1 second later
207-
expect(membership.getLocalExpiry()).toEqual(7000);
115+
expect(membership.getLocalExpiry()).toEqual(DEFAULT_EXPIRE_DURATION + 2000);
208116
});
209117

210118
it("calculates time until expiry", () => {
211119
jest.setSystemTime(2000);
212120
// should be using absolute expiry time
213-
expect(membership.getMsUntilExpiry()).toEqual(4000);
121+
expect(membership.getMsUntilExpiry()).toEqual(DEFAULT_EXPIRE_DURATION - 1000);
214122
});
215123
});
216124
});

0 commit comments

Comments
 (0)