From 3d536dd986c833e08d8dac57dd090ec9061a73e0 Mon Sep 17 00:00:00 2001 From: Dominik Henneke Date: Mon, 8 May 2023 11:58:34 +0200 Subject: [PATCH] Fix type and test Signed-off-by: Dominik Henneke --- src/stores/widgets/StopGapWidget.ts | 2 +- test/stores/widgets/StopGapWidget-test.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/stores/widgets/StopGapWidget.ts b/src/stores/widgets/StopGapWidget.ts index 25479653d84..3f63a9705e6 100644 --- a/src/stores/widgets/StopGapWidget.ts +++ b/src/stores/widgets/StopGapWidget.ts @@ -221,7 +221,7 @@ export class StopGapWidget extends EventEmitter { clientId: ELEMENT_CLIENT_ID, clientTheme: SettingsStore.getValue("theme"), clientLanguage: getUserLanguage(), - deviceId: this.client.getDeviceId(), + deviceId: this.client.getDeviceId() ?? undefined, }; const templated = this.mockWidget.getCompleteUrl(Object.assign(defaults, fromCustomisation), opts?.asPopout); diff --git a/test/stores/widgets/StopGapWidget-test.ts b/test/stores/widgets/StopGapWidget-test.ts index da7612a3bf1..89e626a4f02 100644 --- a/test/stores/widgets/StopGapWidget-test.ts +++ b/test/stores/widgets/StopGapWidget-test.ts @@ -15,6 +15,7 @@ limitations under the License. */ import { mocked, MockedObject } from "jest-mock"; +import { last } from "lodash"; import { MatrixEvent } from "matrix-js-sdk/src/matrix"; import { MatrixClient, ClientEvent } from "matrix-js-sdk/src/client"; import { ClientWidgetApi } from "matrix-widget-api"; @@ -42,7 +43,7 @@ describe("StopGapWidget", () => { id: "test", creatorUserId: "@alice:example.org", type: "example", - url: "https://example.org?user-id=$matrix_user_id&device-id=$org.matrix.msc3819.device_id", + url: "https://example.org?user-id=$matrix_user_id&device-id=$org.matrix.msc3819.matrix_device_id", roomId: "!1:example.org", }, room: mkRoom(client, "!1:example.org"), @@ -53,7 +54,7 @@ describe("StopGapWidget", () => { }); // Start messaging without an iframe, since ClientWidgetApi is mocked widget.startMessaging(null as unknown as HTMLIFrameElement); - messaging = mocked(mocked(ClientWidgetApi).mock.instances[0]); + messaging = mocked(last(mocked(ClientWidgetApi).mock.instances)!); }); afterEach(() => {