convert test-utils to typescript (#7877)
* move js utils into directory Signed-off-by: Kerry Archibald <kerrya@element.io> * typescripterize js test-utils Signed-off-by: Kerry Archibald <kerrya@element.io> * move test utils to directory Signed-off-by: Kerry Archibald <kerrya@element.io> * move remaining mock functions to directory Signed-off-by: Kerry Archibald <kerrya@element.io> * update imports Signed-off-by: Kerry Archibald <kerrya@element.io> * missed copyright Signed-off-by: Kerry Archibald <kerrya@element.io> * type wait for update Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
93a9af7b3a
commit
5e76d988ca
13 changed files with 269 additions and 201 deletions
|
@ -22,8 +22,11 @@ import SpaceStore from "../../../src/stores/spaces/SpaceStore";
|
|||
import { MetaSpace, UPDATE_HOME_BEHAVIOUR } from "../../../src/stores/spaces";
|
||||
import { stubClient } from "../../test-utils";
|
||||
import { SettingLevel } from "../../../src/settings/SettingLevel";
|
||||
import * as testUtils from "../../utils/test-utils";
|
||||
import { setupAsyncStoreWithClient } from "../../utils/test-utils";
|
||||
import {
|
||||
mkSpace,
|
||||
emitPromise,
|
||||
setupAsyncStoreWithClient,
|
||||
} from "../../test-utils";
|
||||
import { MatrixClientPeg } from "../../../src/MatrixClientPeg";
|
||||
import { SpaceFilterCondition } from "../../../src/stores/room-list/filters/SpaceFilterCondition";
|
||||
import DMRoomMap from "../../../src/utils/DMRoomMap";
|
||||
|
@ -49,12 +52,12 @@ describe("SpaceWatcher", () => {
|
|||
const client = MatrixClientPeg.get();
|
||||
|
||||
let rooms = [];
|
||||
const mkSpace = (spaceId: string, children: string[] = []) => testUtils.mkSpace(client, spaceId, rooms, children);
|
||||
const mkSpaceForRooms = (spaceId: string, children: string[] = []) => mkSpace(client, spaceId, rooms, children);
|
||||
|
||||
const setShowAllRooms = async (value: boolean) => {
|
||||
if (store.allRoomsInHome === value) return;
|
||||
await SettingsStore.setValue("Spaces.allRoomsInHome", null, SettingLevel.DEVICE, value);
|
||||
await testUtils.emitPromise(store, UPDATE_HOME_BEHAVIOUR);
|
||||
await emitPromise(store, UPDATE_HOME_BEHAVIOUR);
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
|
@ -63,8 +66,8 @@ describe("SpaceWatcher", () => {
|
|||
store.setActiveSpace(MetaSpace.Home);
|
||||
client.getVisibleRooms.mockReturnValue(rooms = []);
|
||||
|
||||
mkSpace(space1);
|
||||
mkSpace(space2);
|
||||
mkSpaceForRooms(space1);
|
||||
mkSpaceForRooms(space2);
|
||||
|
||||
await SettingsStore.setValue("Spaces.enabledMetaSpaces", null, SettingLevel.DEVICE, {
|
||||
[MetaSpace.Home]: true,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue