Conform more code to strict null checking (#10169)

* Conform more code to strict null checking

* delint

* Iterate

* delint

* Fix bad test
This commit is contained in:
Michael Telatynski 2023-02-16 09:38:44 +00:00 committed by GitHub
parent 5123d7e641
commit e8b92b308b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
85 changed files with 283 additions and 287 deletions

View file

@ -21,7 +21,7 @@ import { Key } from "../../../../src/Keyboard";
import { mockPlatformPeg, unmockPlatformPeg } from "../../../test-utils/platform";
import { KeyboardKey, KeyboardShortcut } from "../../../../src/components/views/settings/KeyboardShortcut";
const renderKeyboardShortcut = (Component: React.FunctionComponentFactory<any>, props: Record<string, any>) => {
const renderKeyboardShortcut = (Component: React.FunctionComponent<any>, props: Record<string, any>) => {
return render(<Component {...props} />).container;
};

View file

@ -30,7 +30,6 @@ describe("<DeviceDetails />", () => {
};
const defaultProps: ComponentProps<typeof DeviceDetails> = {
device: baseDevice,
pusher: null,
isSigningOut: false,
onSignOutDevice: jest.fn(),
saveDeviceName: jest.fn(),

View file

@ -53,7 +53,7 @@ describe("<SelectableDeviceTile />", () => {
const { container } = render(getComponent({ onSelect }));
act(() => {
fireEvent.click(container.querySelector(`#device-tile-checkbox-${device.device_id}`));
fireEvent.click(container.querySelector(`#device-tile-checkbox-${device.device_id}`)!);
});
expect(onSelect).toHaveBeenCalled();

View file

@ -92,7 +92,7 @@ describe("deleteDevices()", () => {
// opened modal
expect(modalSpy).toHaveBeenCalled();
const [, { title, authData, aestheticsForStagePhases }] = modalSpy.mock.calls[0];
const { title, authData, aestheticsForStagePhases } = modalSpy.mock.calls[0][1]!;
// modal opened as expected
expect(title).toEqual("Authentication");

View file

@ -21,7 +21,7 @@ import { DeviceInfo } from "matrix-js-sdk/src/crypto/deviceinfo";
import { logger } from "matrix-js-sdk/src/logger";
import { DeviceTrustLevel } from "matrix-js-sdk/src/crypto/CrossSigning";
import { VerificationRequest } from "matrix-js-sdk/src/crypto/verification/request/VerificationRequest";
import { sleep } from "matrix-js-sdk/src/utils";
import { defer, sleep } from "matrix-js-sdk/src/utils";
import {
ClientEvent,
IMyDevice,
@ -927,12 +927,9 @@ describe("<SessionManagerTab />", () => {
// get a handle for resolving the delete call
// because promise flushing after the confirm modal is resolving this too
// and we want to test the loading state here
let resolveDeleteRequest: (v?: IAuthData) => void;
const resolveDeleteRequest = defer<IAuthData>();
mockClient.deleteMultipleDevices.mockImplementation(() => {
const promise = new Promise<IAuthData>((resolve) => {
resolveDeleteRequest = resolve;
});
return promise;
return resolveDeleteRequest.promise;
});
const { getByTestId } = render(getComponent());
@ -972,7 +969,7 @@ describe("<SessionManagerTab />", () => {
undefined,
);
resolveDeleteRequest?.();
resolveDeleteRequest.resolve({});
});
it("signs out of all other devices from other sessions context menu", async () => {