Eliminate the use of MatrixClientPeg in utils (#10910)
This commit is contained in:
parent
a0c2676c38
commit
30429df948
108 changed files with 409 additions and 325 deletions
|
@ -90,7 +90,7 @@ describe("ForwardDialog", () => {
|
|||
};
|
||||
|
||||
beforeEach(() => {
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(mockClient);
|
||||
jest.clearAllMocks();
|
||||
mockClient.getUserId.mockReturnValue("@bob:example.org");
|
||||
mockClient.getSafeUserId.mockReturnValue("@bob:example.org");
|
||||
|
|
|
@ -143,7 +143,7 @@ describe("InviteDialog", () => {
|
|||
getClientWellKnown: jest.fn().mockResolvedValue({}),
|
||||
});
|
||||
SdkConfig.put({ validated_server_config: {} as ValidatedServerConfig } as IConfigOptions);
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(mockClient);
|
||||
jest.clearAllMocks();
|
||||
|
||||
room = new Room(roomId, mockClient, mockClient.getSafeUserId());
|
||||
|
|
|
@ -86,7 +86,7 @@ describe("AppTile", () => {
|
|||
cli.hasLazyLoadMembersEnabled = () => false;
|
||||
|
||||
// Init misc. startup deps
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(cli);
|
||||
|
||||
r1 = new Room("r1", cli, "@name:example.com");
|
||||
r2 = new Room("r2", cli, "@name:example.com");
|
||||
|
|
|
@ -75,7 +75,7 @@ describe("<Pill>", () => {
|
|||
beforeEach(() => {
|
||||
client = mocked(stubClient());
|
||||
SdkContextClass.instance.client = client;
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(client);
|
||||
room1 = new Room(room1Id, client, user1Id);
|
||||
room1.name = "Room 1";
|
||||
const user1JoinRoom1Event = mkRoomMemberJoinEvent(user1Id, room1Id, {
|
||||
|
|
|
@ -120,7 +120,7 @@ describe("<TextualBody />", () => {
|
|||
);
|
||||
|
||||
it("renders m.emote correctly", () => {
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(defaultMatrixClient);
|
||||
|
||||
const ev = mkEvent({
|
||||
type: "m.room.message",
|
||||
|
@ -140,7 +140,7 @@ describe("<TextualBody />", () => {
|
|||
});
|
||||
|
||||
it("renders m.notice correctly", () => {
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(defaultMatrixClient);
|
||||
|
||||
const ev = mkEvent({
|
||||
type: "m.room.message",
|
||||
|
@ -161,7 +161,7 @@ describe("<TextualBody />", () => {
|
|||
|
||||
describe("renders plain-text m.text correctly", () => {
|
||||
beforeEach(() => {
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(defaultMatrixClient);
|
||||
});
|
||||
|
||||
it("simple message renders as expected", () => {
|
||||
|
@ -264,7 +264,7 @@ describe("<TextualBody />", () => {
|
|||
isGuest: () => false,
|
||||
mxcUrlToHttp: (s: string) => s,
|
||||
});
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(defaultMatrixClient);
|
||||
});
|
||||
|
||||
it("italics, bold, underline and strikethrough render as expected", () => {
|
||||
|
@ -408,7 +408,7 @@ describe("<TextualBody />", () => {
|
|||
isGuest: () => false,
|
||||
mxcUrlToHttp: (s: string) => s,
|
||||
});
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(defaultMatrixClient);
|
||||
|
||||
const ev = mkRoomTextMessage("Visit https://matrix.org/");
|
||||
const { container, rerender } = getComponent(
|
||||
|
|
|
@ -71,7 +71,7 @@ describe("<RoomSummaryCard />", () => {
|
|||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(mockClient);
|
||||
|
||||
mockClient.getRoom.mockReturnValue(room);
|
||||
jest.spyOn(room, "isElementVideoRoom").mockRestore();
|
||||
|
|
|
@ -97,7 +97,7 @@ describe("<EditMessageComposer/>", () => {
|
|||
|
||||
userEvent.setup();
|
||||
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(mockClient);
|
||||
|
||||
jest.spyOn(Autocompleter.prototype, "getCompletions").mockResolvedValue([
|
||||
{
|
||||
|
|
|
@ -47,7 +47,7 @@ describe("NewRoomIntro", () => {
|
|||
|
||||
beforeAll(() => {
|
||||
client = stubClient();
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(client);
|
||||
});
|
||||
|
||||
describe("for a DM Room", () => {
|
||||
|
|
|
@ -112,7 +112,7 @@ describe("RoomHeader", () => {
|
|||
[MediaDeviceKindEnum.AudioOutput]: [],
|
||||
});
|
||||
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(client);
|
||||
jest.spyOn(DMRoomMap.shared(), "getUserIdForRoomId").mockReturnValue(carol.userId);
|
||||
});
|
||||
|
||||
|
@ -761,7 +761,7 @@ function createRoom(info: IRoomCreationInfo) {
|
|||
};
|
||||
}
|
||||
|
||||
DMRoomMap.makeShared().start();
|
||||
DMRoomMap.makeShared(client).start();
|
||||
|
||||
const room = new Room(roomId, client, userId, {
|
||||
pendingEventOrdering: PendingEventOrdering.Detached,
|
||||
|
|
|
@ -33,8 +33,9 @@ jest.mock("../../../../src/IdentityAuthClient", () => {
|
|||
jest.useRealTimers();
|
||||
|
||||
const createRoom = (roomId: string, userId: string): Room => {
|
||||
const newRoom = new Room(roomId, MatrixClientPeg.get(), userId, {});
|
||||
DMRoomMap.makeShared().start();
|
||||
const cli = MatrixClientPeg.get();
|
||||
const newRoom = new Room(roomId, cli, userId, {});
|
||||
DMRoomMap.makeShared(cli).start();
|
||||
return newRoom;
|
||||
};
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ describe("RoomPreviewCard", () => {
|
|||
stubClient();
|
||||
client = mocked(MatrixClientPeg.get());
|
||||
client.getUserId.mockReturnValue("@alice:example.org");
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(client);
|
||||
|
||||
room = new Room("!1:example.org", client, "@alice:example.org", {
|
||||
pendingEventOrdering: PendingEventOrdering.Detached,
|
||||
|
|
|
@ -90,7 +90,7 @@ describe("RoomTile", () => {
|
|||
|
||||
client = mocked(stubClient());
|
||||
sdkContext.client = client;
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(client);
|
||||
|
||||
room = new Room("!1:example.org", client, "@alice:example.org", {
|
||||
pendingEventOrdering: PendingEventOrdering.Detached,
|
||||
|
|
|
@ -159,7 +159,7 @@ describe("<SpacePanel />", () => {
|
|||
mkStubRoom("!room2:server", "Room 2", mockClient),
|
||||
mkStubRoom("!room3:server", "Room 3", mockClient),
|
||||
];
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(mockClient);
|
||||
jest.useFakeTimers();
|
||||
|
||||
const { getByLabelText } = render(<SpacePanel />);
|
||||
|
|
|
@ -40,7 +40,7 @@ jest.mock("../../../../src/stores/spaces/SpaceStore", () => {
|
|||
describe("SpaceButton", () => {
|
||||
stubClient();
|
||||
const space = mkRoom(MatrixClientPeg.get(), "!1:example.org");
|
||||
DMRoomMap.makeShared();
|
||||
DMRoomMap.makeShared(MatrixClientPeg.get());
|
||||
|
||||
const dispatchSpy = jest.spyOn(defaultDispatcher, "dispatch");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue