Handle SDKContextClass client initialisation internally (#34146)
* Handle SDKContextClass `client` initialisation internally Rather than via MatrixChat - this is predominantly for Lifecycle tests as they don't use a MatrixChat and it doesn't make much sense for this component to own this state. * Fix tests
This commit is contained in:
@@ -33,6 +33,7 @@ import DMRoomMap from "../../../../src/utils/DMRoomMap";
|
||||
import { mediaFromMxc } from "../../../../src/customisations/Media";
|
||||
import SettingsStore from "../../../../src/settings/SettingsStore";
|
||||
import { SDKContextClass } from "../../../../src/contexts/SDKContextClass";
|
||||
import { TestSDKContext } from "../../TestSDKContext.ts";
|
||||
|
||||
jest.mock("jszip");
|
||||
jest.mock("../../../../src/settings/SettingsStore");
|
||||
@@ -93,6 +94,7 @@ const EVENT_MENTION: IRoomEvent = {
|
||||
describe("HTMLExport", () => {
|
||||
let client: jest.Mocked<MatrixClient>;
|
||||
let room: Room;
|
||||
let sdkContext: TestSDKContext;
|
||||
|
||||
filterConsole(
|
||||
"Starting export",
|
||||
@@ -111,7 +113,10 @@ describe("HTMLExport", () => {
|
||||
jest.setSystemTime(REPEATABLE_DATE);
|
||||
|
||||
client = stubClient() as jest.Mocked<MatrixClient>;
|
||||
SDKContextClass.instance.client = client;
|
||||
sdkContext = new TestSDKContext();
|
||||
// @ts-ignore HTMLExport uses SDKContext in the constructor
|
||||
SDKContextClass.instance = sdkContext;
|
||||
sdkContext._client = client;
|
||||
DMRoomMap.makeShared(client);
|
||||
|
||||
room = new Room("!myroom:example.org", client, "@me:example.org");
|
||||
|
||||
Reference in New Issue
Block a user