mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Switch to running injection token based setups over legacy DI setups in unit tests
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
1 parent
4d79d25b6e
commit
cf87bc14d9
10 files changed
+49
-35
No files matched your search
@@ -24,6 +24,7 @@ import directoryForUserDataInjectable from "../app-paths/directory-for-user-data
|
||||
import { getDiForUnitTesting } from "../../main/getDiForUnitTesting";
|
||||
import getConfigurationFileModelInjectable from "../get-configuration-file-model/get-configuration-file-model.injectable";
|
||||
import appVersionInjectable from "../get-configuration-file-model/app-version/app-version.injectable";
|
||||
import { runSetupables } from "../setupable-injection-token/run-setupables";
|
||||
|
||||
console = new Console(stdout, stderr);
|
||||
|
||||
@@ -82,6 +83,8 @@ describe("cluster-store", () => {
|
||||
beforeEach(async () => {
|
||||
mainDi = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||
|
||||
await runSetupables(mainDi);
|
||||
|
||||
mockFs();
|
||||
|
||||
mainDi.override(clusterStoreInjectable, (di) => ClusterStore.createInstance({ createCluster: di.inject(createClusterInjectionToken) }));
|
||||
@@ -90,8 +93,6 @@ describe("cluster-store", () => {
|
||||
mainDi.permitSideEffects(getConfigurationFileModelInjectable);
|
||||
mainDi.permitSideEffects(appVersionInjectable);
|
||||
|
||||
await mainDi.runSetups();
|
||||
|
||||
createCluster = mainDi.inject(createClusterInjectionToken);
|
||||
});
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import hotbarStoreInjectable from "../hotbar-store.injectable";
|
||||
import { HotbarStore } from "../hotbar-store";
|
||||
import catalogCatalogEntityInjectable from "../catalog-entities/general-catalog-entities/implementations/catalog-catalog-entity.injectable";
|
||||
import { runSetupables } from "../setupable-injection-token/run-setupables";
|
||||
|
||||
jest.mock("../../main/catalog/catalog-entity-registry", () => ({
|
||||
catalogEntityRegistry: {
|
||||
@@ -150,7 +151,7 @@ describe("HotbarStore", () => {
|
||||
beforeEach(async () => {
|
||||
mockFs();
|
||||
|
||||
await di.runSetups();
|
||||
await runSetupables(di);
|
||||
|
||||
hotbarStore = di.inject(hotbarStoreInjectable);
|
||||
});
|
||||
@@ -381,7 +382,7 @@ describe("HotbarStore", () => {
|
||||
|
||||
mockFs(configurationToBeMigrated);
|
||||
|
||||
await di.runSetups();
|
||||
await runSetupables(di);
|
||||
|
||||
hotbarStore = di.inject(hotbarStoreInjectable);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
import type { DiContainer } from "@ogre-tools/injectable";
|
||||
import { setupableInjectionToken } from "./setupable-injection-token";
|
||||
|
||||
export const runSetupables = async (di: DiContainer) => {
|
||||
await Promise.all(
|
||||
di
|
||||
.injectMany(setupableInjectionToken)
|
||||
.map((setupable) => setupable.doSetup()),
|
||||
);
|
||||
};
|
||||
Reference in new issue
Block a user