Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
27 changes: 16 additions & 11 deletions spec/integ/matrix-client-methods.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,14 @@ describe("MatrixClient", function() {
describe("joinRoom", function() {
it("should no-op if you've already joined a room", function() {
const roomId = "!foo:bar";
const room = new Room(roomId, userId);
const room = new Room(roomId, client, userId);
client.fetchRoomEvent = () => Promise.resolve({});
room.addLiveEvents([
utils.mkMembership({
user: userId, room: roomId, mship: "join", event: true,
}),
]);
httpBackend.verifyNoOutstandingRequests();
store.storeRoom(room);
client.joinRoom(roomId);
httpBackend.verifyNoOutstandingRequests();
Expand Down Expand Up @@ -556,11 +558,14 @@ describe("MatrixClient", function() {
});

describe("partitionThreadedEvents", function() {
const room = new Room("!STrMRsukXHtqQdSeHa:matrix.org", client, userId);
let room;
beforeEach(() => {
room = new Room("!STrMRsukXHtqQdSeHa:matrix.org", client, userId);
});

it("returns empty arrays when given an empty arrays", function() {
const events = [];
const [timeline, threaded] = client.partitionThreadedEvents(room, events);
const [timeline, threaded] = room.partitionThreadedEvents(events);
expect(timeline).toEqual([]);
expect(threaded).toEqual([]);
});
Expand All @@ -580,7 +585,7 @@ describe("MatrixClient", function() {
// Vote has no threadId yet
expect(eventPollResponseReference.threadId).toBeFalsy();

const [timeline, threaded] = client.partitionThreadedEvents(room, events);
const [timeline, threaded] = room.partitionThreadedEvents(events);

expect(timeline).toEqual([
// The message that was sent in a thread is missing
Expand Down Expand Up @@ -613,7 +618,7 @@ describe("MatrixClient", function() {
eventReaction,
];

const [timeline, threaded] = client.partitionThreadedEvents(room, events);
const [timeline, threaded] = room.partitionThreadedEvents(events);

expect(timeline).toEqual([
eventPollStartThreadRoot,
Expand All @@ -640,7 +645,7 @@ describe("MatrixClient", function() {
eventMessageInThread,
];

const [timeline, threaded] = client.partitionThreadedEvents(room, events);
const [timeline, threaded] = room.partitionThreadedEvents(events);

expect(timeline).toEqual([
eventPollStartThreadRoot,
Expand All @@ -667,7 +672,7 @@ describe("MatrixClient", function() {
eventReaction,
];

const [timeline, threaded] = client.partitionThreadedEvents(room, events);
const [timeline, threaded] = room.partitionThreadedEvents(events);

expect(timeline).toEqual([
eventPollStartThreadRoot,
Expand Down Expand Up @@ -710,7 +715,7 @@ describe("MatrixClient", function() {
eventMember,
eventCreate,
];
const [timeline, threaded] = client.partitionThreadedEvents(room, events);
const [timeline, threaded] = room.partitionThreadedEvents(events);

expect(timeline).toEqual([
// The message that was sent in a thread is missing
Expand Down Expand Up @@ -749,7 +754,7 @@ describe("MatrixClient", function() {
threadedReactionRedaction,
];

const [timeline, threaded] = client.partitionThreadedEvents(room, events);
const [timeline, threaded] = room.partitionThreadedEvents(events);

expect(timeline).toEqual([
threadRootEvent,
Expand Down Expand Up @@ -778,7 +783,7 @@ describe("MatrixClient", function() {
replyToReply,
];

const [timeline, threaded] = client.partitionThreadedEvents(room, events);
const [timeline, threaded] = room.partitionThreadedEvents(events);

expect(timeline).toEqual([
threadRootEvent,
Expand All @@ -805,7 +810,7 @@ describe("MatrixClient", function() {
replyToThreadResponse,
];

const [timeline, threaded] = client.partitionThreadedEvents(room, events);
const [timeline, threaded] = room.partitionThreadedEvents(events);

expect(timeline).toEqual([
threadRootEvent,
Expand Down
1 change: 1 addition & 0 deletions spec/test-utils/test-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export function mkEvent(opts: IEventOpts): object | MatrixEvent {
content: opts.content,
unsigned: opts.unsigned || {},
event_id: "$" + Math.random() + "-" + Math.random(),
txn_id: "~" + Math.random(),
redacts: opts.redacts,
};
if (opts.skey !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion spec/unit/matrix-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ describe("MatrixClient", function() {

expect(rootEvent.isThreadRoot).toBe(true);

const [roomEvents, threadEvents] = client.partitionThreadedEvents(room, [rootEvent]);
const [roomEvents, threadEvents] = room.partitionThreadedEvents([rootEvent]);
expect(roomEvents).toHaveLength(1);
expect(threadEvents).toHaveLength(1);

Expand Down
Loading