1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-07-28 15:22:05 +03:00

Make more code conform to strict null checks (#10219

* Make more code conform to strict null checks

* Fix types

* Fix tests

* Fix remaining test assertions

* Iterate PR
This commit is contained in:
Michael Telatynski
2023-02-24 15:28:40 +00:00
committed by GitHub
parent 4c79ecf141
commit 76b82b4b2b
130 changed files with 603 additions and 603 deletions

View File

@ -78,22 +78,16 @@ describe("createRoom", () => {
const createCallSpy = jest.spyOn(ElementCall, "create");
const roomId = await createRoom({ roomType: RoomType.UnstableCall });
const [
[
{
power_level_content_override: {
users: { [userId]: userPower },
events: {
[ElementCall.CALL_EVENT_TYPE.name]: callPower,
[ElementCall.MEMBER_EVENT_TYPE.name]: callMemberPower,
},
},
},
],
] = client.createRoom.mock.calls;
const userPower = client.createRoom.mock.calls[0][0].power_level_content_override?.users?.[userId];
const callPower =
client.createRoom.mock.calls[0][0].power_level_content_override?.events?.[ElementCall.CALL_EVENT_TYPE.name];
const callMemberPower =
client.createRoom.mock.calls[0][0].power_level_content_override?.events?.[
ElementCall.MEMBER_EVENT_TYPE.name
];
// We should have had enough power to be able to set up the call
expect(userPower).toBeGreaterThanOrEqual(callPower);
expect(userPower).toBeGreaterThanOrEqual(callPower!);
// and should have actually set it up
expect(createCallSpy).toHaveBeenCalled();
@ -122,18 +116,12 @@ describe("createRoom", () => {
await createRoom({});
const [
[
{
power_level_content_override: {
events: {
[ElementCall.CALL_EVENT_TYPE.name]: callPower,
[ElementCall.MEMBER_EVENT_TYPE.name]: callMemberPower,
},
},
},
],
] = client.createRoom.mock.calls;
const callPower =
client.createRoom.mock.calls[0][0].power_level_content_override?.events?.[ElementCall.CALL_EVENT_TYPE.name];
const callMemberPower =
client.createRoom.mock.calls[0][0].power_level_content_override?.events?.[
ElementCall.MEMBER_EVENT_TYPE.name
];
expect(callPower).toBe(100);
expect(callMemberPower).toBe(100);