mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-15 20:54:59 +08:00
More tests
This commit is contained in:
parent
8e774e1924
commit
6a75054e1a
@ -322,11 +322,7 @@ export class SlidingSyncManager {
|
|||||||
// gradually request more over time, even on errors.
|
// gradually request more over time, even on errors.
|
||||||
await sleep(gapBetweenRequestsMs);
|
await sleep(gapBetweenRequestsMs);
|
||||||
}
|
}
|
||||||
const listData = this.slidingSync.getListData(SlidingSyncManager.ListSearch);
|
const listData = this.slidingSync.getListData(SlidingSyncManager.ListSearch)!;
|
||||||
if (!listData) {
|
|
||||||
// we failed to do the first request, keep trying
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
hasMore = endIndex + 1 < listData.joinedCount;
|
hasMore = endIndex + 1 < listData.joinedCount;
|
||||||
startIndex += batchSize;
|
startIndex += batchSize;
|
||||||
firstTime = false;
|
firstTime = false;
|
||||||
|
@ -290,4 +290,43 @@ describe("SlidingRoomListStore", () => {
|
|||||||
await p;
|
await p;
|
||||||
expect(store.orderedLists[tagId].map((r) => r.roomId)).toEqual([roomC, roomA, roomB].map((r) => r.roomId));
|
expect(store.orderedLists[tagId].map((r) => r.roomId)).toEqual([roomC, roomA, roomB].map((r) => r.roomId));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("gracefully handles unknown room IDs", async () => {
|
||||||
|
await store.start();
|
||||||
|
const roomIdA = "!a:localhost";
|
||||||
|
const roomIdB = "!b:localhost"; // does not exist
|
||||||
|
const roomIdC = "!c:localhost";
|
||||||
|
const roomIndexToRoomId = {
|
||||||
|
0: roomIdA,
|
||||||
|
1: roomIdB, // does not exist
|
||||||
|
2: roomIdC,
|
||||||
|
};
|
||||||
|
const tagId = DefaultTagID.Favourite;
|
||||||
|
const joinCount = 10;
|
||||||
|
// seed the store with 2 rooms
|
||||||
|
const roomA = new Room(roomIdA, context.client!, context.client!.getUserId());
|
||||||
|
const roomC = new Room(roomIdC, context.client!, context.client!.getUserId());
|
||||||
|
mocked(context.client!.getRoom).mockImplementation((roomId: string) => {
|
||||||
|
switch (roomId) {
|
||||||
|
case roomIdA:
|
||||||
|
return roomA;
|
||||||
|
case roomIdC:
|
||||||
|
return roomC;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
mocked(context._SlidingSyncManager!.slidingSync.getListData).mockImplementation((key: string) => {
|
||||||
|
if (key !== tagId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
roomIndexToRoomId: roomIndexToRoomId,
|
||||||
|
joinedCount: joinCount,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
let p = untilEmission(store, LISTS_UPDATE_EVENT);
|
||||||
|
context.slidingSyncManager.slidingSync.emit(SlidingSyncEvent.List, tagId, joinCount, roomIndexToRoomId);
|
||||||
|
await p;
|
||||||
|
expect(store.orderedLists[tagId]).toEqual([roomA, roomC]);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user