You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Conform more code to strictNullChecks
(#10444
* Conform more code to `strictNullChecks` * Fix tests * Fix tests
This commit is contained in:
committed by
GitHub
parent
ba2608ec74
commit
c225b8ec29
@@ -716,7 +716,7 @@ describe("MessagePanel", function () {
|
||||
// Increase the length of the loop here to test performance issues with
|
||||
// rendering
|
||||
|
||||
const events = [];
|
||||
const events: MatrixEvent[] = [];
|
||||
for (let i = 0; i < 100; i++) {
|
||||
events.push(
|
||||
TestUtilsMatrix.mkMembership({
|
||||
|
@@ -54,6 +54,7 @@ describe("ForwardDialog", () => {
|
||||
});
|
||||
const mockClient = getMockClientWithEventEmitter({
|
||||
getUserId: jest.fn().mockReturnValue(aliceId),
|
||||
getSafeUserId: jest.fn().mockReturnValue(aliceId),
|
||||
isGuest: jest.fn().mockReturnValue(false),
|
||||
getVisibleRooms: jest.fn().mockReturnValue([]),
|
||||
getRoom: jest.fn(),
|
||||
@@ -92,6 +93,7 @@ describe("ForwardDialog", () => {
|
||||
DMRoomMap.makeShared();
|
||||
jest.clearAllMocks();
|
||||
mockClient.getUserId.mockReturnValue("@bob:example.org");
|
||||
mockClient.getSafeUserId.mockReturnValue("@bob:example.org");
|
||||
mockClient.sendEvent.mockReset();
|
||||
});
|
||||
|
||||
|
@@ -112,6 +112,7 @@ const mockClient = mocked({
|
||||
setIgnoredUsers: jest.fn(),
|
||||
isCryptoEnabled: jest.fn(),
|
||||
getUserId: jest.fn(),
|
||||
getSafeUserId: jest.fn(),
|
||||
on: jest.fn(),
|
||||
off: jest.fn(),
|
||||
isSynapseAdministrator: jest.fn().mockResolvedValue(false),
|
||||
@@ -348,6 +349,7 @@ describe("<DeviceItem />", () => {
|
||||
});
|
||||
|
||||
it("when userId is the same as userId from client, uses isCrossSigningVerified to determine if button is shown", () => {
|
||||
mockClient.getSafeUserId.mockReturnValueOnce(defaultUserId);
|
||||
mockClient.getUserId.mockReturnValueOnce(defaultUserId);
|
||||
renderComponent();
|
||||
|
||||
@@ -431,6 +433,7 @@ describe("<UserOptionsSection />", () => {
|
||||
});
|
||||
|
||||
it("does not show ignore or direct message buttons when member userId matches client userId", () => {
|
||||
mockClient.getSafeUserId.mockReturnValueOnce(member.userId);
|
||||
mockClient.getUserId.mockReturnValueOnce(member.userId);
|
||||
renderComponent();
|
||||
|
||||
@@ -676,6 +679,7 @@ describe("<PowerLevelEditor />", () => {
|
||||
content: { users: { [defaultUserId]: startPowerLevel }, users_default: 1 },
|
||||
});
|
||||
mockRoom.currentState.getStateEvents.mockReturnValue(powerLevelEvent);
|
||||
mockClient.getSafeUserId.mockReturnValueOnce(defaultUserId);
|
||||
mockClient.getUserId.mockReturnValueOnce(defaultUserId);
|
||||
mockClient.setPowerLevel.mockResolvedValueOnce({ event_id: "123" });
|
||||
renderComponent();
|
||||
@@ -879,7 +883,7 @@ describe("<BanToggleButton />", () => {
|
||||
},
|
||||
};
|
||||
|
||||
expect(callback(mockRoom)).toBe(null);
|
||||
expect(callback(mockRoom)).toBe(false);
|
||||
expect(callback(mockRoom)).toBe(true);
|
||||
});
|
||||
|
||||
|
Reference in New Issue
Block a user