Write more tests

This commit is contained in:
R Midhun Suresh
2025-02-28 15:25:59 +05:30
parent 06d9852f50
commit 3da4576e10

View File

@@ -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);
});
});