Conform more of the codebase to strictNullChecks + noImplicitAny (#11179)
This commit is contained in:
parent
7c211b0587
commit
a294ba2ad4
17 changed files with 104 additions and 88 deletions
|
@ -332,16 +332,18 @@ describe("<RoomPreviewBar />", () => {
|
|||
{ medium: "not-email", address: "address 2" },
|
||||
];
|
||||
|
||||
const testJoinButton = (props: ComponentProps<typeof RoomPreviewBar>) => async () => {
|
||||
const onJoinClick = jest.fn();
|
||||
const onRejectClick = jest.fn();
|
||||
const component = getComponent({ ...props, onJoinClick, onRejectClick });
|
||||
await new Promise(setImmediate);
|
||||
expect(getPrimaryActionButton(component)).toBeTruthy();
|
||||
expect(getSecondaryActionButton(component)).toBeFalsy();
|
||||
fireEvent.click(getPrimaryActionButton(component)!);
|
||||
expect(onJoinClick).toHaveBeenCalled();
|
||||
};
|
||||
const testJoinButton =
|
||||
(props: ComponentProps<typeof RoomPreviewBar>, expectSecondaryButton = false) =>
|
||||
async () => {
|
||||
const onJoinClick = jest.fn();
|
||||
const onRejectClick = jest.fn();
|
||||
const component = getComponent({ ...props, onJoinClick, onRejectClick });
|
||||
await new Promise(setImmediate);
|
||||
expect(getPrimaryActionButton(component)).toBeTruthy();
|
||||
if (expectSecondaryButton) expect(getSecondaryActionButton(component)).toBeFalsy();
|
||||
fireEvent.click(getPrimaryActionButton(component)!);
|
||||
expect(onJoinClick).toHaveBeenCalled();
|
||||
};
|
||||
|
||||
describe("when client fails to get 3PIDs", () => {
|
||||
beforeEach(() => {
|
||||
|
@ -399,7 +401,7 @@ describe("<RoomPreviewBar />", () => {
|
|||
});
|
||||
|
||||
it("renders email mismatch message when invite email mxid doesnt match", async () => {
|
||||
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue("not userid");
|
||||
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue({ mxid: "not userid" });
|
||||
const component = getComponent({ inviterName, invitedEmail });
|
||||
await new Promise(setImmediate);
|
||||
|
||||
|
@ -413,12 +415,12 @@ describe("<RoomPreviewBar />", () => {
|
|||
});
|
||||
|
||||
it("renders invite message when invite email mxid match", async () => {
|
||||
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue(userId);
|
||||
MatrixClientPeg.safeGet().lookupThreePid = jest.fn().mockReturnValue({ mxid: userId });
|
||||
const component = getComponent({ inviterName, invitedEmail });
|
||||
await new Promise(setImmediate);
|
||||
|
||||
expect(getMessage(component)).toMatchSnapshot();
|
||||
await testJoinButton({ inviterName, invitedEmail })();
|
||||
await testJoinButton({ inviterName, invitedEmail }, false)();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue