Change module API to be an instance getter (#31025)

* Change module API to be an instance getter

Helps with circular dependencies by not instantating the module API
on the initial evaluation of the files.

* Add basic test

* add another test
This commit is contained in:
David Baker
2025-10-15 10:20:48 +01:00
committed by GitHub
parent 6cfe197a38
commit 146e4772ac
8 changed files with 82 additions and 23 deletions

View File

@@ -16,7 +16,7 @@ import { MatrixClientPeg } from "../../../../../src/MatrixClientPeg";
import DMRoomMap from "../../../../../src/utils/DMRoomMap";
import RoomPreviewBar from "../../../../../src/components/views/rooms/RoomPreviewBar";
import defaultDispatcher from "../../../../../src/dispatcher/dispatcher";
import ModuleApi from "../../../../../src/modules/Api.ts";
import { ModuleApi } from "../../../../../src/modules/Api.ts";
jest.mock("../../../../../src/IdentityAuthClient", () => {
return jest.fn().mockImplementation(() => {
@@ -500,7 +500,7 @@ describe("<RoomPreviewBar />", () => {
});
it("should render Module roomPreviewBarRenderer if specified", () => {
jest.spyOn(ModuleApi.customComponents, "roomPreviewBarRenderer", "get").mockReturnValue(() => (
jest.spyOn(ModuleApi.instance.customComponents, "roomPreviewBarRenderer", "get").mockReturnValue(() => (
<>Test component</>
));
const { getByText } = render(<RoomPreviewBar />);