You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-09 08:42:50 +03:00
Use MatrixClientPeg::safeGet in src/components/views/* (#10987)
This commit is contained in:
committed by
GitHub
parent
4243847f4f
commit
280f6a9d93
@@ -49,6 +49,7 @@ describe("EncryptionEvent", () => {
|
||||
jest.clearAllMocks();
|
||||
client = createTestClient();
|
||||
jest.spyOn(MatrixClientPeg, "get").mockReturnValue(client);
|
||||
jest.spyOn(MatrixClientPeg, "safeGet").mockReturnValue(client);
|
||||
event = mkMessage({
|
||||
event: true,
|
||||
room: roomId,
|
||||
|
@@ -166,6 +166,7 @@ beforeEach(() => {
|
||||
} as unknown as MatrixClient);
|
||||
|
||||
jest.spyOn(MatrixClientPeg, "get").mockReturnValue(mockClient);
|
||||
jest.spyOn(MatrixClientPeg, "safeGet").mockReturnValue(mockClient);
|
||||
});
|
||||
|
||||
describe("<UserInfo />", () => {
|
||||
|
@@ -18,7 +18,7 @@ import React, { ComponentProps } from "react";
|
||||
import { render, fireEvent, RenderResult, waitFor } from "@testing-library/react";
|
||||
import { Room, RoomMember, MatrixError, IContent } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { stubClient } from "../../../test-utils";
|
||||
import { withClientContextRenderOptions, stubClient } from "../../../test-utils";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import DMRoomMap from "../../../../src/utils/DMRoomMap";
|
||||
import RoomPreviewBar from "../../../../src/components/views/rooms/RoomPreviewBar";
|
||||
@@ -77,7 +77,10 @@ describe("<RoomPreviewBar />", () => {
|
||||
roomId,
|
||||
room: createRoom(roomId, userId),
|
||||
};
|
||||
return render(<RoomPreviewBar {...defaultProps} {...props} />);
|
||||
return render(
|
||||
<RoomPreviewBar {...defaultProps} {...props} />,
|
||||
withClientContextRenderOptions(MatrixClientPeg.safeGet()),
|
||||
);
|
||||
};
|
||||
|
||||
const isSpinnerRendered = (wrapper: RenderResult) => !!wrapper.container.querySelector(".mx_Spinner");
|
||||
@@ -92,7 +95,10 @@ describe("<RoomPreviewBar />", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
MatrixClientPeg.get().getUserId = jest.fn().mockReturnValue(userId);
|
||||
MatrixClientPeg.get().getSafeUserId = jest.fn().mockReturnValue(userId);
|
||||
MatrixClientPeg.safeGet().getUserId = jest.fn().mockReturnValue(userId);
|
||||
MatrixClientPeg.safeGet().getSafeUserId = jest.fn().mockReturnValue(userId);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
@@ -127,6 +127,7 @@ describe("<SpacePanel />", () => {
|
||||
|
||||
beforeAll(() => {
|
||||
jest.spyOn(MatrixClientPeg, "get").mockReturnValue(mockClient);
|
||||
jest.spyOn(MatrixClientPeg, "safeGet").mockReturnValue(mockClient);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
|
Reference in New Issue
Block a user