Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add non-optional client to Room instances
  • Loading branch information
MadLittleMods committed Jul 13, 2022
commit a3457e198a835f175d790c4e1882295413438b9c
19 changes: 14 additions & 5 deletions spec/unit/relations.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,19 @@ import { EventTimelineSet } from "../../src/models/event-timeline-set";
import { MatrixEvent, MatrixEventEvent } from "../../src/models/event";
import { Room } from "../../src/models/room";
import { Relations } from "../../src/models/relations";
import { MatrixClient } from "../../src";
import { TestClient } from "../TestClient";

describe("Relations", function() {
let client: MatrixClient;
beforeEach(() => {
client = (new TestClient(
"@alice:example.com", "alicedevice",
)).client;
})

it("should deduplicate annotations", function() {
const room = new Room("room123", null, null);
const room = new Room("room123", client, null);
const relations = new Relations("m.annotation", "m.reaction", room);

// Create an instance of an annotation
Expand Down Expand Up @@ -98,7 +107,7 @@ describe("Relations", function() {

// Add the target event first, then the relation event
{
const room = new Room("room123", null, null);
const room = new Room("room123", client, null);
const relationsCreated = new Promise(resolve => {
targetEvent.once(MatrixEventEvent.RelationsCreated, resolve);
});
Expand All @@ -112,7 +121,7 @@ describe("Relations", function() {

// Add the relation event first, then the target event
{
const room = new Room("room123", null, null);
const room = new Room("room123", client, null);
const relationsCreated = new Promise(resolve => {
targetEvent.once(MatrixEventEvent.RelationsCreated, resolve);
});
Expand All @@ -126,7 +135,7 @@ describe("Relations", function() {
});

it("should re-use Relations between all timeline sets in a room", async () => {
const room = new Room("room123", null, null);
const room = new Room("room123", client, null);
const timelineSet1 = new EventTimelineSet(room);
const timelineSet2 = new EventTimelineSet(room);
expect(room.relations).toBe(timelineSet1.relations);
Expand All @@ -135,7 +144,7 @@ describe("Relations", function() {

it("should ignore m.replace for state events", async () => {
const userId = "@bob:example.com";
const room = new Room("room123", null, userId);
const room = new Room("room123", client, userId);
const relations = new Relations("m.replace", "m.room.topic", room);

// Create an instance of a state event with rel_type m.replace
Expand Down
5 changes: 4 additions & 1 deletion spec/unit/room.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,10 @@ describe("Room", function() {
});

it("should remove cancelled events from the timeline", function() {
const room = new Room(roomId, null, userA);
const client = (new TestClient(
"@alice:example.com", "alicedevice",
)).client;
const room = new Room(roomId, client, userA);
const eventA = utils.mkMessage({
room: roomId, user: userA, event: true,
});
Expand Down