Fix broken jest tests
This commit is contained in:
@@ -26,10 +26,16 @@ describe("RoomListStoreV3", () => {
|
||||
client.getVisibleRooms = jest.fn().mockReturnValue(rooms);
|
||||
jest.spyOn(AsyncStoreWithClient.prototype, "matrixClient", "get").mockReturnValue(client);
|
||||
const store = new RoomListStoreV3Class(dispatcher);
|
||||
store.start();
|
||||
await store.start();
|
||||
return { client, rooms, store, dispatcher };
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SpaceStore.instance, "isRoomInSpace").mockImplementation((space) => space === MetaSpace.Home);
|
||||
jest.spyOn(SpaceStore.instance, "activeSpace", "get").mockImplementation(() => MetaSpace.Home);
|
||||
jest.spyOn(SpaceStore.instance, "isReady", "get").mockImplementation(() => Promise.resolve());
|
||||
});
|
||||
|
||||
it("Provides an unsorted list of rooms", async () => {
|
||||
const { store, rooms } = await getRoomListStore();
|
||||
expect(store.getRooms()).toEqual(rooms);
|
||||
@@ -280,7 +286,6 @@ describe("RoomListStoreV3", () => {
|
||||
jest.spyOn(AsyncStoreWithClient.prototype, "matrixClient", "get").mockReturnValue(client);
|
||||
|
||||
// Mock the space store
|
||||
jest.spyOn(SpaceStore.instance, "isReady", "get").mockImplementation(() => Promise.resolve());
|
||||
jest.spyOn(SpaceStore.instance, "isRoomInSpace").mockImplementation((space, id) => {
|
||||
if (space === MetaSpace.Home && !roomIds.includes(id)) return true;
|
||||
if (space === spaceRoom.roomId && roomIds.includes(id)) return true;
|
||||
|
||||
@@ -14,6 +14,8 @@ import { RoomSkipList } from "../../../../../src/stores/room-list-v3/skip-list/R
|
||||
import { RecencySorter } from "../../../../../src/stores/room-list-v3/skip-list/sorters/RecencySorter";
|
||||
import { AlphabeticSorter } from "../../../../../src/stores/room-list-v3/skip-list/sorters/AlphabeticSorter";
|
||||
import { getMockedRooms } from "./getMockedRooms";
|
||||
import SpaceStore from "../../../../../src/stores/spaces/SpaceStore";
|
||||
import { MetaSpace } from "../../../../../src/stores/spaces";
|
||||
|
||||
describe("RoomSkipList", () => {
|
||||
function generateSkipList(roomCount?: number): {
|
||||
@@ -30,6 +32,12 @@ describe("RoomSkipList", () => {
|
||||
return { skipList, rooms, totalRooms: rooms.length, sorter };
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
jest.spyOn(SpaceStore.instance, "isRoomInSpace").mockImplementation((space) => space === MetaSpace.Home);
|
||||
jest.spyOn(SpaceStore.instance, "activeSpace", "get").mockImplementation(() => MetaSpace.Home);
|
||||
jest.spyOn(SpaceStore.instance, "isReady", "get").mockImplementation(() => Promise.resolve());
|
||||
});
|
||||
|
||||
it("Rooms are in sorted order after initial seed", () => {
|
||||
const { skipList, totalRooms } = generateSkipList();
|
||||
expect(skipList.size).toEqual(totalRooms);
|
||||
|
||||
Reference in New Issue
Block a user