Fix tests
This commit is contained in:
parent
50b6c5c557
commit
316b21408d
8 changed files with 31 additions and 18 deletions
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "../skinned-sdk"; // Must be first for skinning to work
|
||||||
import { getLineAndNodePosition } from "../../src/editor/caret";
|
import { getLineAndNodePosition } from "../../src/editor/caret";
|
||||||
import EditorModel from "../../src/editor/model";
|
import EditorModel from "../../src/editor/model";
|
||||||
import { createPartCreator } from "./mock";
|
import { createPartCreator } from "./mock";
|
||||||
|
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "../skinned-sdk"; // Must be first for skinning to work
|
||||||
import EditorModel from "../../src/editor/model";
|
import EditorModel from "../../src/editor/model";
|
||||||
import { createPartCreator, createRenderer } from "./mock";
|
import { createPartCreator, createRenderer } from "./mock";
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "../skinned-sdk"; // Must be first for skinning to work
|
||||||
import EditorModel from "../../src/editor/model";
|
import EditorModel from "../../src/editor/model";
|
||||||
import { createPartCreator, createRenderer } from "./mock";
|
import { createPartCreator, createRenderer } from "./mock";
|
||||||
import { toggleInlineFormat } from "../../src/editor/operations";
|
import { toggleInlineFormat } from "../../src/editor/operations";
|
||||||
|
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "../skinned-sdk"; // Must be first for skinning to work
|
||||||
import EditorModel from "../../src/editor/model";
|
import EditorModel from "../../src/editor/model";
|
||||||
import { createPartCreator } from "./mock";
|
import { createPartCreator } from "./mock";
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "../skinned-sdk"; // Must be first for skinning to work
|
||||||
import EditorModel from "../../src/editor/model";
|
import EditorModel from "../../src/editor/model";
|
||||||
import { createPartCreator, createRenderer } from "./mock";
|
import { createPartCreator, createRenderer } from "./mock";
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import "../skinned-sdk"; // Must be first for skinning to work
|
||||||
import EditorModel from "../../src/editor/model";
|
import EditorModel from "../../src/editor/model";
|
||||||
import { htmlSerializeIfNeeded } from "../../src/editor/serialize";
|
import { htmlSerializeIfNeeded } from "../../src/editor/serialize";
|
||||||
import { createPartCreator } from "./mock";
|
import { createPartCreator } from "./mock";
|
||||||
|
|
23
test/stores/SpaceStore-setup.ts
Normal file
23
test/stores/SpaceStore-setup.ts
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
Copyright 2021 The Matrix.org Foundation C.I.C.
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This needs to be executed before the SpaceStore gets imported but due to ES6 import hoisting we have to do this here.
|
||||||
|
// SpaceStore reads the SettingsStore which needs the localStorage values set at init time.
|
||||||
|
|
||||||
|
localStorage.setItem("mx_labs_feature_feature_spaces", "true");
|
||||||
|
localStorage.setItem("mx_labs_feature_feature_spaces.all_rooms", "true");
|
||||||
|
localStorage.setItem("mx_labs_feature_feature_spaces.space_member_dms", "true");
|
||||||
|
localStorage.setItem("mx_labs_feature_feature_spaces.space_dm_badges", "false");
|
|
@ -16,7 +16,9 @@ limitations under the License.
|
||||||
|
|
||||||
import { EventEmitter } from "events";
|
import { EventEmitter } from "events";
|
||||||
import { EventType } from "matrix-js-sdk/src/@types/event";
|
import { EventType } from "matrix-js-sdk/src/@types/event";
|
||||||
|
import { MatrixEvent } from "matrix-js-sdk/src/models/event";
|
||||||
|
|
||||||
|
import "./SpaceStore-setup"; // enable space lab
|
||||||
import "../skinned-sdk"; // Must be first for skinning to work
|
import "../skinned-sdk"; // Must be first for skinning to work
|
||||||
import SpaceStore, {
|
import SpaceStore, {
|
||||||
UPDATE_INVITED_SPACES,
|
UPDATE_INVITED_SPACES,
|
||||||
|
@ -26,13 +28,10 @@ import SpaceStore, {
|
||||||
import { resetAsyncStoreWithClient, setupAsyncStoreWithClient } from "../utils/test-utils";
|
import { resetAsyncStoreWithClient, setupAsyncStoreWithClient } from "../utils/test-utils";
|
||||||
import { mkEvent, mkStubRoom, stubClient } from "../test-utils";
|
import { mkEvent, mkStubRoom, stubClient } from "../test-utils";
|
||||||
import { EnhancedMap } from "../../src/utils/maps";
|
import { EnhancedMap } from "../../src/utils/maps";
|
||||||
import SettingsStore from "../../src/settings/SettingsStore";
|
|
||||||
import DMRoomMap from "../../src/utils/DMRoomMap";
|
import DMRoomMap from "../../src/utils/DMRoomMap";
|
||||||
import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
import { MatrixClientPeg } from "../../src/MatrixClientPeg";
|
||||||
import defaultDispatcher from "../../src/dispatcher/dispatcher";
|
import defaultDispatcher from "../../src/dispatcher/dispatcher";
|
||||||
|
|
||||||
type MatrixEvent = any; // importing from js-sdk upsets things
|
|
||||||
|
|
||||||
jest.useFakeTimers();
|
jest.useFakeTimers();
|
||||||
|
|
||||||
const mockStateEventImplementation = (events: MatrixEvent[]) => {
|
const mockStateEventImplementation = (events: MatrixEvent[]) => {
|
||||||
|
@ -79,9 +78,6 @@ const mkSpace = (spaceId: string, children: string[] = []) => {
|
||||||
return space;
|
return space;
|
||||||
};
|
};
|
||||||
|
|
||||||
const getValue = jest.fn();
|
|
||||||
SettingsStore.getValue = getValue;
|
|
||||||
|
|
||||||
const getUserIdForRoomId = jest.fn();
|
const getUserIdForRoomId = jest.fn();
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
DMRoomMap.sharedInstance = { getUserIdForRoomId };
|
DMRoomMap.sharedInstance = { getUserIdForRoomId };
|
||||||
|
@ -122,18 +118,6 @@ describe("SpaceStore", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.runAllTimers();
|
jest.runAllTimers();
|
||||||
client.getVisibleRooms.mockReturnValue(rooms = []);
|
client.getVisibleRooms.mockReturnValue(rooms = []);
|
||||||
getValue.mockImplementation(settingName => {
|
|
||||||
switch (settingName) {
|
|
||||||
case "feature_spaces":
|
|
||||||
return true;
|
|
||||||
case "feature_spaces.all_rooms":
|
|
||||||
return true;
|
|
||||||
case "feature_spaces.space_member_dms":
|
|
||||||
return true;
|
|
||||||
case "feature_spaces.space_dm_badges":
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
afterEach(async () => {
|
afterEach(async () => {
|
||||||
await resetAsyncStoreWithClient(store);
|
await resetAsyncStoreWithClient(store);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue