diff --git a/test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts b/test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts index cd58c428e6..cd37b04e34 100644 --- a/test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts +++ b/test/unit-tests/stores/room-list-v3/RoomListStoreV3-test.ts @@ -11,6 +11,7 @@ import { AsyncStoreWithClient } from "../../../../src/stores/AsyncStoreWithClien import { RecencySorter } from "../../../../src/stores/room-list-v3/skip-list/sorters/RecencySorter"; import { stubClient } from "../../../test-utils"; import { getMockedRooms } from "./skip-list/getMockedRooms"; +import { AlphabeticSorter } from "../../../../src/stores/room-list-v3/skip-list/sorters/AlphabeticSorter"; describe("RoomListStoreV3", () => { async function getRoomListStore() { @@ -35,4 +36,18 @@ describe("RoomListStoreV3", () => { const sortedRooms = sorter.sort(rooms); expect(store.getSortedRooms()).toEqual(sortedRooms); }); + + it("Provides a way to resort", async () => { + const { store, rooms, client } = await getRoomListStore(); + + // List is sorted by recency, sort by alphabetical now + store.useAlphabeticSorting(); + let sortedRooms = new AlphabeticSorter().sort(rooms); + expect(store.getSortedRooms()).toEqual(sortedRooms); + + // Go back to recency sorting + store.useRecencySorting(); + sortedRooms = new RecencySorter(client.getSafeUserId()).sort(rooms); + expect(store.getSortedRooms()).toEqual(sortedRooms); + }); });