From b79912e390a6fb0b70e46317228b7c0db8c22bef Mon Sep 17 00:00:00 2001 From: Michael Weimann Date: Tue, 3 Jan 2023 10:16:46 +0100 Subject: [PATCH] Improve strict typing --- src/Modal.tsx | 4 ++-- test/Notifier-test.ts | 14 ++++++++------ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/Modal.tsx b/src/Modal.tsx index 290c082344..c9f737f9ae 100644 --- a/src/Modal.tsx +++ b/src/Modal.tsx @@ -107,8 +107,8 @@ export class ModalManager extends TypedEventEmitter 0; + public hasDialogs(): boolean { + return !!(this.priorityModal || this.staticModal || this.modals.length > 0); } public createDialog( diff --git a/test/Notifier-test.ts b/test/Notifier-test.ts index 36021e6f6f..a3b1f9b2db 100644 --- a/test/Notifier-test.ts +++ b/test/Notifier-test.ts @@ -112,11 +112,11 @@ describe("Notifier", () => { }); mockClient.pushRules = { - global: undefined, + global: {}, }; - accountDataEventKey = getLocalNotificationAccountDataEventType(mockClient.deviceId); + accountDataEventKey = getLocalNotificationAccountDataEventType(mockClient.deviceId!); - testRoom = new Room(roomId, mockClient, mockClient.getUserId()); + testRoom = new Room(roomId, mockClient, mockClient.getSafeUserId()); MockPlatform = mockPlatformPeg({ supportsNotifications: jest.fn().mockReturnValue(true), @@ -127,8 +127,10 @@ describe("Notifier", () => { Notifier.isBodyEnabled = jest.fn().mockReturnValue(true); - mockClient.getRoom.mockImplementation((id) => { - return id === roomId ? testRoom : new Room(id, mockClient, mockClient.getUserId()); + mockClient.getRoom.mockImplementation((id: string | undefined): Room | null => { + if (id === roomId) return testRoom; + if (id) return new Room(id, mockClient, mockClient.getSafeUserId()); + return null; }); }); @@ -484,7 +486,7 @@ describe("Notifier", () => { dis.dispatch({ action: Action.ViewThread, - thread_id: rootEvent.getId(), + thread_id: rootEvent.getId()!, }); await waitFor(() => expect(SdkContextClass.instance.roomViewStore.getThreadId()).toBe(rootEvent.getId()));