Separate out SDKContext (#34053)
* Separate out SDKContext ...from SDKContextClass, as the comments hopefully explain. Also make the captitalisation consistent. * Adding the new file usually helps too * Fix import * More comment * Update the various imports of SDKContextClass * Also fix case of TestSDKContext * Update the mock
This commit is contained in:
@@ -30,7 +30,7 @@ import DMRoomMap from "../../../../../src/utils/DMRoomMap";
|
||||
import SdkConfig from "../../../../../src/SdkConfig";
|
||||
import { type ValidatedServerConfig } from "../../../../../src/utils/ValidatedServerConfig";
|
||||
import { type IConfigOptions } from "../../../../../src/IConfigOptions";
|
||||
import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||
import { SDKContextClass } from "../../../../../src/contexts/SDKContextClass";
|
||||
import { type IProfileInfo } from "../../../../../src/hooks/useProfileInfo";
|
||||
import { DirectoryMember, startDmOnFirstMessage } from "../../../../../src/utils/direct-messages";
|
||||
|
||||
@@ -178,13 +178,13 @@ describe("InviteDialog", () => {
|
||||
mockClient.getRooms.mockReturnValue([room]);
|
||||
mockClient.getRoom.mockReturnValue(room);
|
||||
|
||||
SdkContextClass.instance.client = mockClient;
|
||||
SDKContextClass.instance.client = mockClient;
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await clearAllModals();
|
||||
SdkContextClass.instance.onLoggedOut();
|
||||
SdkContextClass.instance.client = undefined;
|
||||
SDKContextClass.instance.onLoggedOut();
|
||||
SDKContextClass.instance.client = undefined;
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
@@ -13,12 +13,13 @@ import { EventType, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import type { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
import { flushPromises, mkMessage, stubClient } from "../../../../test-utils";
|
||||
import MessageEditHistoryDialog from "../../../../../src/components/views/dialogs/MessageEditHistoryDialog";
|
||||
import { SDKContext, SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||
import { SDKContext } from "../../../../../src/contexts/SDKContext";
|
||||
import { SDKContextClass } from "../../../../../src/contexts/SDKContextClass";
|
||||
|
||||
describe("<MessageEditHistory />", () => {
|
||||
const roomId = "!aroom:example.com";
|
||||
let client: jest.Mocked<MatrixClient>;
|
||||
let sdkContext: SdkContextClass;
|
||||
let sdkContext: SDKContextClass;
|
||||
let event: MatrixEvent;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -29,7 +30,7 @@ describe("<MessageEditHistory />", () => {
|
||||
room: "!room:example.com",
|
||||
msg: "My Great Message",
|
||||
});
|
||||
sdkContext = new SdkContextClass();
|
||||
sdkContext = new SDKContextClass();
|
||||
});
|
||||
|
||||
async function renderComponent(): Promise<RenderResult> {
|
||||
|
||||
@@ -24,7 +24,7 @@ import MatrixClientContext from "../../../../../src/contexts/MatrixClientContext
|
||||
import SettingsStore from "../../../../../src/settings/SettingsStore";
|
||||
import { UIFeature } from "../../../../../src/settings/UIFeature";
|
||||
import DMRoomMap from "../../../../../src/utils/DMRoomMap";
|
||||
import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||
import { SDKContextClass } from "../../../../../src/contexts/SDKContextClass";
|
||||
|
||||
describe("<RoomSettingsDialog />", () => {
|
||||
const userId = "@alice:server.org";
|
||||
@@ -44,7 +44,7 @@ describe("<RoomSettingsDialog />", () => {
|
||||
const room2 = new Room("!room2:server.org", mockClient, userId);
|
||||
room2.name = "Another Room";
|
||||
|
||||
let sdkContext: SdkContextClass;
|
||||
let sdkContext: SDKContextClass;
|
||||
|
||||
jest.spyOn(SettingsStore, "getValue");
|
||||
|
||||
@@ -57,7 +57,7 @@ describe("<RoomSettingsDialog />", () => {
|
||||
return null;
|
||||
});
|
||||
|
||||
sdkContext = new SdkContextClass();
|
||||
sdkContext = new SDKContextClass();
|
||||
sdkContext.client = mockClient;
|
||||
|
||||
jest.spyOn(SettingsStore, "getValue").mockReset().mockReturnValue(false);
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
} from "../../../../test-utils";
|
||||
import { UIFeature } from "../../../../../src/settings/UIFeature";
|
||||
import { SettingLevel } from "../../../../../src/settings/SettingLevel";
|
||||
import { SdkContextClass } from "../../../../../src/contexts/SDKContext";
|
||||
import { SDKContextClass } from "../../../../../src/contexts/SDKContextClass";
|
||||
import { type FeatureSettingKey } from "../../../../../src/settings/Settings.tsx";
|
||||
import { mockOpenIdConfiguration } from "../../../../test-utils/oidc.ts";
|
||||
|
||||
@@ -57,7 +57,7 @@ describe("<UserSettingsDialog />", () => {
|
||||
const mockSettingsStore = mocked(SettingsStore);
|
||||
let mockClient!: MockedObject<MatrixClient>;
|
||||
|
||||
let sdkContext: SdkContextClass;
|
||||
let sdkContext: SDKContextClass;
|
||||
const defaultProps = { onFinished: jest.fn() };
|
||||
const getComponent = (
|
||||
props: Partial<typeof defaultProps & { initialTabId?: UserTab; props: Record<string, any> }> = {},
|
||||
@@ -76,7 +76,7 @@ describe("<UserSettingsDialog />", () => {
|
||||
getMediaConfig: jest.fn(),
|
||||
getAuthMetadata: jest.fn().mockResolvedValue(mockOpenIdConfiguration()),
|
||||
});
|
||||
sdkContext = new SdkContextClass();
|
||||
sdkContext = new SDKContextClass();
|
||||
sdkContext.client = mockClient;
|
||||
mockSettingsStore.getValue.mockReturnValue(false);
|
||||
mockSettingsStore.getValueAt.mockReturnValue(false);
|
||||
|
||||
Reference in New Issue
Block a user