From 32fde84dc03f0fc1ee2f5db575b15c7edbcb214d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=A8=20Audrey=20=E2=9C=A8?= Date: Wed, 26 Feb 2025 15:37:48 -0500 Subject: [PATCH] fix unit test type --- .../integration/integration-context.spec.ts | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/libs/common/src/tools/integration/integration-context.spec.ts b/libs/common/src/tools/integration/integration-context.spec.ts index 42581c08dee..026470dddf9 100644 --- a/libs/common/src/tools/integration/integration-context.spec.ts +++ b/libs/common/src/tools/integration/integration-context.spec.ts @@ -1,6 +1,7 @@ import { mock } from "jest-mock-extended"; import { I18nService } from "../../platform/abstractions/i18n.service"; +import { VendorId } from "../extension"; import { IntegrationContext } from "./integration-context"; import { IntegrationId } from "./integration-id"; @@ -8,7 +9,7 @@ import { IntegrationMetadata } from "./integration-metadata"; const EXAMPLE_META = Object.freeze({ // arbitrary - id: "simplelogin" as IntegrationId, + id: "simplelogin" as IntegrationId & VendorId, name: "Example", // arbitrary extends: ["forwarder"], @@ -25,7 +26,7 @@ describe("IntegrationContext", () => { describe("baseUrl", () => { it("outputs the base url from metadata", () => { - const context = new IntegrationContext(EXAMPLE_META, null, i18n); + const context = new IntegrationContext(EXAMPLE_META, null!, i18n); const result = context.baseUrl(); @@ -34,14 +35,14 @@ describe("IntegrationContext", () => { it("throws when the baseurl isn't defined in metadata", () => { const noBaseUrl: IntegrationMetadata = { - id: "simplelogin" as IntegrationId, // arbitrary + id: "simplelogin" as IntegrationId & VendorId, // arbitrary name: "Example", extends: ["forwarder"], // arbitrary selfHost: "maybe", }; i18n.t.mockReturnValue("error"); - const context = new IntegrationContext(noBaseUrl, null, i18n); + const context = new IntegrationContext(noBaseUrl, null!, i18n); expect(() => context.baseUrl()).toThrow("error"); }); @@ -56,7 +57,7 @@ describe("IntegrationContext", () => { it("ignores settings when selfhost is 'never'", () => { const selfHostNever: IntegrationMetadata = { - id: "simplelogin" as IntegrationId, // arbitrary + id: "simplelogin" as IntegrationId & VendorId, // arbitrary name: "Example", extends: ["forwarder"], // arbitrary baseUrl: "example.com", @@ -71,7 +72,7 @@ describe("IntegrationContext", () => { it("always reads the settings when selfhost is 'always'", () => { const selfHostAlways: IntegrationMetadata = { - id: "simplelogin" as IntegrationId, // arbitrary + id: "simplelogin" as IntegrationId & VendorId, // arbitrary name: "Example", extends: ["forwarder"], // arbitrary baseUrl: "example.com", @@ -86,7 +87,7 @@ describe("IntegrationContext", () => { it("fails when the settings are empty and selfhost is 'always'", () => { const selfHostAlways: IntegrationMetadata = { - id: "simplelogin" as IntegrationId, // arbitrary + id: "simplelogin" as IntegrationId & VendorId, // arbitrary name: "Example", extends: ["forwarder"], // arbitrary baseUrl: "example.com", @@ -101,14 +102,14 @@ describe("IntegrationContext", () => { it("reads from the metadata by default when selfhost is 'maybe'", () => { const selfHostMaybe: IntegrationMetadata = { - id: "simplelogin" as IntegrationId, // arbitrary + id: "simplelogin" as IntegrationId & VendorId, // arbitrary name: "Example", extends: ["forwarder"], // arbitrary baseUrl: "example.com", selfHost: "maybe", }; - const context = new IntegrationContext(selfHostMaybe, null, i18n); + const context = new IntegrationContext(selfHostMaybe, null!, i18n); const result = context.baseUrl(); @@ -117,7 +118,7 @@ describe("IntegrationContext", () => { it("overrides the metadata when selfhost is 'maybe'", () => { const selfHostMaybe: IntegrationMetadata = { - id: "simplelogin" as IntegrationId, // arbitrary + id: "simplelogin" as IntegrationId & VendorId, // arbitrary name: "Example", extends: ["forwarder"], // arbitrary baseUrl: "example.com", @@ -174,7 +175,7 @@ describe("IntegrationContext", () => { describe("website", () => { it("returns the website", () => { - const context = new IntegrationContext(EXAMPLE_META, null, i18n); + const context = new IntegrationContext(EXAMPLE_META, null!, i18n); const result = context.website({ website: "www.example.com" }); @@ -182,7 +183,7 @@ describe("IntegrationContext", () => { }); it("returns an empty string when the website is not specified", () => { - const context = new IntegrationContext(EXAMPLE_META, null, i18n); + const context = new IntegrationContext(EXAMPLE_META, null!, i18n); const result = context.website({ website: undefined }); @@ -192,7 +193,7 @@ describe("IntegrationContext", () => { describe("generatedBy", () => { it("creates generated by text", () => { - const context = new IntegrationContext(EXAMPLE_META, null, i18n); + const context = new IntegrationContext(EXAMPLE_META, null!, i18n); i18n.t.mockReturnValue("result"); const result = context.generatedBy({ website: null }); @@ -202,7 +203,7 @@ describe("IntegrationContext", () => { }); it("creates generated by text including the website", () => { - const context = new IntegrationContext(EXAMPLE_META, null, i18n); + const context = new IntegrationContext(EXAMPLE_META, null!, i18n); i18n.t.mockReturnValue("result"); const result = context.generatedBy({ website: "www.example.com" });