Skip to content

Commit 2459214

Browse files
committed
Add tests
1 parent 8082118 commit 2459214

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

apps/web/src/stores/room-list-v3/RoomListStoreV3.test.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,32 @@ describe("RoomListStoreV3", () => {
11761176
]);
11771177
});
11781178

1179+
it("does not load the sections before the matrix client is ready", () => {
1180+
enableSections();
1181+
const getOrderedSectionTagsSpy = vi.spyOn(sectionModule, "getOrderedSectionTags");
1182+
1183+
// Constructing the store must not read the sections yet: at this point account data
1184+
// (e.g. custom section ordering) may not have been loaded, so sections would be empty.
1185+
const store = new RoomListStoreV3Class(dispatcher);
1186+
1187+
expect(getOrderedSectionTagsSpy).not.toHaveBeenCalled();
1188+
expect(store.orderedSectionTags).toEqual([]);
1189+
});
1190+
1191+
it("loads the sections once the store becomes ready", async () => {
1192+
enableSections();
1193+
getClientAndRooms();
1194+
const getOrderedSectionTagsSpy = vi.spyOn(sectionModule, "getOrderedSectionTags");
1195+
1196+
const store = new RoomListStoreV3Class(dispatcher);
1197+
expect(getOrderedSectionTagsSpy).not.toHaveBeenCalled();
1198+
1199+
await store.start();
1200+
1201+
expect(getOrderedSectionTagsSpy).toHaveBeenCalled();
1202+
expect(store.orderedSectionTags).toEqual([DefaultTagID.Favourite, CHATS_TAG, DefaultTagID.LowPriority]);
1203+
});
1204+
11791205
describe("RoomList.showSections disabled", () => {
11801206
function disableSections(): void {
11811207
vi.spyOn(SettingsStore, "getValue").mockImplementation((setting: string) => {

0 commit comments

Comments
 (0)