From b3432c6439a3e4713e18ce25b470272c491c9abc Mon Sep 17 00:00:00 2001 From: MartinSchuhmacher Date: Mon, 22 Jan 2024 14:09:25 +0100 Subject: [PATCH 1/4] refactor ContextExternalToolConfigurationStatus.composable test file --- ...nalToolConfigurationStatus.composable.unit.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/components/data-external-tool/ContextExternalToolConfigurationStatus.composable.unit.ts b/src/components/data-external-tool/ContextExternalToolConfigurationStatus.composable.unit.ts index 0a395af6ae..c1b7decd7b 100644 --- a/src/components/data-external-tool/ContextExternalToolConfigurationStatus.composable.unit.ts +++ b/src/components/data-external-tool/ContextExternalToolConfigurationStatus.composable.unit.ts @@ -37,7 +37,6 @@ describe("ToolConfigurationStatus.composable", () => { return { toolConfigurationStatus, ...composable, - authModule, }; }; @@ -79,7 +78,6 @@ describe("ToolConfigurationStatus.composable", () => { return { toolConfigurationStatus, ...composable, - authModule, }; }; @@ -121,7 +119,6 @@ describe("ToolConfigurationStatus.composable", () => { return { toolConfigurationStatus, ...composable, - authModule, }; }; @@ -265,13 +262,16 @@ describe("ToolConfigurationStatus.composable", () => { const composable = mountComposable( () => useContextExternalToolConfigurationStatus(), { - [AUTH_MODULE_KEY.valueOf()]: authModule, + global: { + provide: { + [AUTH_MODULE_KEY.valueOf()]: authModule, + }, + }, } ); return { ...composable, - authModule, }; }; @@ -295,7 +295,11 @@ describe("ToolConfigurationStatus.composable", () => { const composable = mountComposable( () => useContextExternalToolConfigurationStatus(), { - [AUTH_MODULE_KEY.valueOf()]: authModule, + global: { + provide: { + [AUTH_MODULE_KEY.valueOf()]: authModule, + }, + }, } ); From ce07e778d050b6e1f05d2366aebcc08eaabca5c2 Mon Sep 17 00:00:00 2001 From: MartinSchuhmacher Date: Mon, 22 Jan 2024 14:11:46 +0100 Subject: [PATCH 2/4] refactor ExternalToolLaunchState.composable test file --- .../ExternalToolLaunchState.composable.unit.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts b/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts index 053a45bb3d..d3cef5cd04 100644 --- a/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts +++ b/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts @@ -25,8 +25,13 @@ describe("ExternalToolLaunchState.composable", () => { afterEach(() => { jest.clearAllMocks(); - - window.location.href = ""; + Object.defineProperty(window, "location", { + configurable: true, + writable: false, + value: { + href: "", + }, + }); }); describe("fetchLaunchRequest", () => { @@ -233,6 +238,10 @@ describe("ExternalToolLaunchState.composable", () => { }); describe("when the launch method is unknown", () => { + beforeEach(() => { + window.location.href = ""; + }); + const setup = () => { const launchRequest = toolLaunchRequestFactory.build({ method: "unknown" as unknown as ToolLaunchRequestMethodEnum, From 50e19a59c13ebf6a8394aa440a9dfef541716e1c Mon Sep 17 00:00:00 2001 From: MartinSchuhmacher Date: Mon, 22 Jan 2024 15:51:17 +0100 Subject: [PATCH 3/4] fix structure --- ...ExternalToolLaunchState.composable.unit.ts | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts b/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts index d3cef5cd04..3e2515b544 100644 --- a/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts +++ b/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts @@ -13,6 +13,14 @@ import { useExternalToolLaunchState } from "./ExternalToolLaunchState.composable jest.mock("@data-external-tool/ExternalToolApi.composable"); +Object.defineProperty(window, "location", { + configurable: true, + writable: false, + value: { + href: "", + }, +}); + describe("ExternalToolLaunchState.composable", () => { let useExternalToolApiMock: DeepMocked>; @@ -25,13 +33,7 @@ describe("ExternalToolLaunchState.composable", () => { afterEach(() => { jest.clearAllMocks(); - Object.defineProperty(window, "location", { - configurable: true, - writable: false, - value: { - href: "", - }, - }); + window.location.href = ""; }); describe("fetchLaunchRequest", () => { @@ -238,10 +240,6 @@ describe("ExternalToolLaunchState.composable", () => { }); describe("when the launch method is unknown", () => { - beforeEach(() => { - window.location.href = ""; - }); - const setup = () => { const launchRequest = toolLaunchRequestFactory.build({ method: "unknown" as unknown as ToolLaunchRequestMethodEnum, From addd596531f0a6f66ac141da9ca6321e0cf818b6 Mon Sep 17 00:00:00 2001 From: MartinSchuhmacher Date: Mon, 22 Jan 2024 15:52:46 +0100 Subject: [PATCH 4/4] typo --- .../ExternalToolLaunchState.composable.unit.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts b/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts index 3e2515b544..df07426967 100644 --- a/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts +++ b/src/components/data-external-tool/ExternalToolLaunchState.composable.unit.ts @@ -33,6 +33,7 @@ describe("ExternalToolLaunchState.composable", () => { afterEach(() => { jest.clearAllMocks(); + window.location.href = ""; });