Conform more code to strict null checking (#10167)
* Conform more code to strict null checking * Delint * Iterate PR based on feedback
This commit is contained in:
parent
f7bea2cae5
commit
4574c665ea
103 changed files with 517 additions and 495 deletions
|
@ -34,7 +34,7 @@ describe("RoomStatusBar", () => {
|
|||
|
||||
stubClient();
|
||||
client = MatrixClientPeg.get();
|
||||
room = new Room(ROOM_ID, client, client.getUserId(), {
|
||||
room = new Room(ROOM_ID, client, client.getUserId()!, {
|
||||
pendingEventOrdering: PendingEventOrdering.Detached,
|
||||
});
|
||||
event = mkEvent({
|
||||
|
@ -72,7 +72,7 @@ describe("RoomStatusBar", () => {
|
|||
length: 2,
|
||||
});
|
||||
rootEvent.status = EventStatus.NOT_SENT;
|
||||
room.addPendingEvent(rootEvent, rootEvent.getId());
|
||||
room.addPendingEvent(rootEvent, rootEvent.getId()!);
|
||||
for (const event of events) {
|
||||
event.status = EventStatus.NOT_SENT;
|
||||
room.addPendingEvent(event, Date.now() + Math.random() + "");
|
||||
|
|
|
@ -99,10 +99,10 @@ describe("ThreadView", () => {
|
|||
"is_falling_back": true,
|
||||
"m.in_reply_to": {
|
||||
event_id: rootEvent
|
||||
.getThread()
|
||||
.getThread()!
|
||||
.lastReply((ev: MatrixEvent) => {
|
||||
return ev.isRelation(THREAD_RELATION_TYPE.name);
|
||||
})
|
||||
})!
|
||||
.getId(),
|
||||
},
|
||||
"rel_type": RelationType.Thread,
|
||||
|
@ -126,8 +126,8 @@ describe("ThreadView", () => {
|
|||
const res = mkThread({
|
||||
room,
|
||||
client: mockClient,
|
||||
authorId: mockClient.getUserId(),
|
||||
participantUserIds: [mockClient.getUserId()],
|
||||
authorId: mockClient.getUserId()!,
|
||||
participantUserIds: [mockClient.getUserId()!],
|
||||
});
|
||||
|
||||
rootEvent = res.rootEvent;
|
||||
|
@ -154,8 +154,8 @@ describe("ThreadView", () => {
|
|||
const { rootEvent: rootEvent2 } = mkThread({
|
||||
room,
|
||||
client: mockClient,
|
||||
authorId: mockClient.getUserId(),
|
||||
participantUserIds: [mockClient.getUserId()],
|
||||
authorId: mockClient.getUserId()!,
|
||||
participantUserIds: [mockClient.getUserId()!],
|
||||
});
|
||||
|
||||
act(() => {
|
||||
|
|
|
@ -54,8 +54,8 @@ describe("ThreadListContextMenu", () => {
|
|||
const res = mkThread({
|
||||
room,
|
||||
client: mockClient,
|
||||
authorId: mockClient.getUserId(),
|
||||
participantUserIds: [mockClient.getUserId()],
|
||||
authorId: mockClient.getUserId()!,
|
||||
participantUserIds: [mockClient.getUserId()!],
|
||||
});
|
||||
|
||||
event = res.rootEvent;
|
||||
|
|
|
@ -109,7 +109,7 @@ describe("<ExportDialog />", () => {
|
|||
plainTextExporterInstance.export.mockClear();
|
||||
|
||||
// default setting value
|
||||
ChatExportMock.getForceChatExportParameters.mockClear().mockReturnValue({});
|
||||
mocked(ChatExportMock.getForceChatExportParameters!).mockClear().mockReturnValue({});
|
||||
});
|
||||
|
||||
it("renders export dialog", () => {
|
||||
|
@ -145,7 +145,7 @@ describe("<ExportDialog />", () => {
|
|||
});
|
||||
|
||||
it("exports room using values set from ForceRoomExportParameters", async () => {
|
||||
ChatExportMock.getForceChatExportParameters.mockReturnValue({
|
||||
mocked(ChatExportMock.getForceChatExportParameters!).mockReturnValue({
|
||||
format: ExportFormat.PlainText,
|
||||
range: ExportType.Beginning,
|
||||
sizeMb: 7000,
|
||||
|
@ -198,7 +198,7 @@ describe("<ExportDialog />", () => {
|
|||
});
|
||||
|
||||
it("does not render export format when set in ForceRoomExportParameters", () => {
|
||||
ChatExportMock.getForceChatExportParameters.mockReturnValue({
|
||||
mocked(ChatExportMock.getForceChatExportParameters!).mockReturnValue({
|
||||
format: ExportFormat.PlainText,
|
||||
});
|
||||
const component = getComponent();
|
||||
|
@ -219,7 +219,7 @@ describe("<ExportDialog />", () => {
|
|||
});
|
||||
|
||||
it("does not render export type when set in ForceRoomExportParameters", () => {
|
||||
ChatExportMock.getForceChatExportParameters.mockReturnValue({
|
||||
mocked(ChatExportMock.getForceChatExportParameters!).mockReturnValue({
|
||||
range: ExportType.Beginning,
|
||||
});
|
||||
const component = getComponent();
|
||||
|
@ -310,7 +310,7 @@ describe("<ExportDialog />", () => {
|
|||
});
|
||||
|
||||
it("does not render size limit input when set in ForceRoomExportParameters", () => {
|
||||
ChatExportMock.getForceChatExportParameters.mockReturnValue({
|
||||
mocked(ChatExportMock.getForceChatExportParameters!).mockReturnValue({
|
||||
sizeMb: 10000,
|
||||
});
|
||||
const component = getComponent();
|
||||
|
@ -321,7 +321,7 @@ describe("<ExportDialog />", () => {
|
|||
* 2000mb size limit does not apply when higher limit is configured in config
|
||||
*/
|
||||
it("exports when size limit set in ForceRoomExportParameters is larger than 2000", async () => {
|
||||
ChatExportMock.getForceChatExportParameters.mockReturnValue({
|
||||
mocked(ChatExportMock.getForceChatExportParameters!).mockReturnValue({
|
||||
sizeMb: 10000,
|
||||
});
|
||||
const component = getComponent();
|
||||
|
@ -344,7 +344,7 @@ describe("<ExportDialog />", () => {
|
|||
});
|
||||
|
||||
it("does not render input when set in ForceRoomExportParameters", () => {
|
||||
ChatExportMock.getForceChatExportParameters.mockReturnValue({
|
||||
mocked(ChatExportMock.getForceChatExportParameters!).mockReturnValue({
|
||||
includeAttachments: false,
|
||||
});
|
||||
const component = getComponent();
|
||||
|
|
|
@ -74,7 +74,7 @@ describe("<DevicesPanel />", () => {
|
|||
|
||||
const toggleDeviceSelection = (container: HTMLElement, deviceId: string) =>
|
||||
act(() => {
|
||||
const checkbox = container.querySelector(`#device-tile-checkbox-${deviceId}`);
|
||||
const checkbox = container.querySelector(`#device-tile-checkbox-${deviceId}`)!;
|
||||
fireEvent.click(checkbox);
|
||||
});
|
||||
|
||||
|
@ -204,7 +204,7 @@ describe("<DevicesPanel />", () => {
|
|||
|
||||
// close the modal without submission
|
||||
act(() => {
|
||||
const modalCloseButton = document.querySelector('[aria-label="Close dialog"]');
|
||||
const modalCloseButton = document.querySelector('[aria-label="Close dialog"]')!;
|
||||
fireEvent.click(modalCloseButton);
|
||||
});
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ describe("PreferencesUserSettingsTab", () => {
|
|||
const client = MatrixClientPeg.get();
|
||||
jest.spyOn(client, "isVersionSupported").mockImplementation(async (version: string) => {
|
||||
if (version === "v1.4") return val;
|
||||
return false;
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -61,8 +62,12 @@ describe("PreferencesUserSettingsTab", () => {
|
|||
};
|
||||
};
|
||||
|
||||
const expectSetValueToHaveBeenCalled = (name: string, roomId: string, level: SettingLevel, value: boolean) =>
|
||||
expect(SettingsStore.setValue).toHaveBeenCalledWith(name, roomId, level, value);
|
||||
const expectSetValueToHaveBeenCalled = (
|
||||
name: string,
|
||||
roomId: string | undefined,
|
||||
level: SettingLevel,
|
||||
value: boolean,
|
||||
) => expect(SettingsStore.setValue).toHaveBeenCalledWith(name, roomId, level, value);
|
||||
|
||||
describe("with server support", () => {
|
||||
beforeEach(() => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue