Skip to content

Commit 9f0f782

Browse files
committed
Add more tests
1 parent 44a867f commit 9f0f782

File tree

1 file changed

+54
-0
lines changed

1 file changed

+54
-0
lines changed

test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,5 +184,59 @@ describe("RoomListStoreV3", () => {
184184
);
185185
expect(fn).toHaveBeenCalled();
186186
});
187+
188+
describe("Update from read receipt", () => {
189+
function getReadReceiptEvent(userId: string) {
190+
const content = {
191+
some_id: {
192+
"m.read": {
193+
[userId]: {
194+
ts: 5000,
195+
},
196+
},
197+
},
198+
};
199+
const event = mkEvent({
200+
event: true,
201+
content,
202+
user: "@foo:matrix.org",
203+
type: EventType.Receipt,
204+
});
205+
return event;
206+
}
207+
208+
it("Room is re-inserted on read receipt from our user", async () => {
209+
const { store, rooms, client, dispatcher } = await getRoomListStore();
210+
const event = getReadReceiptEvent(client.getSafeUserId());
211+
const fn = jest.fn();
212+
store.on(LISTS_UPDATE_EVENT, fn);
213+
dispatcher.dispatch(
214+
{
215+
action: "MatrixActions.Room.receipt",
216+
room: rooms[10],
217+
event,
218+
},
219+
true,
220+
);
221+
expect(fn).toHaveBeenCalled();
222+
});
223+
224+
it("Read receipt from other users do not cause room to be re-inserted", async () => {
225+
const { store, rooms, dispatcher } = await getRoomListStore();
226+
const event = getReadReceiptEvent("@foobar:matrix.org");
227+
const fn = jest.fn();
228+
store.on(LISTS_UPDATE_EVENT, fn);
229+
dispatcher.dispatch(
230+
{
231+
action: "MatrixActions.Room.receipt",
232+
room: rooms[10],
233+
event,
234+
},
235+
true,
236+
);
237+
expect(fn).not.toHaveBeenCalled();
238+
});
239+
});
240+
187241
});
188242
});

0 commit comments

Comments
 (0)