1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Mark injectable causing side effects

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne Savolainen 2022-05-25 08:52:21 +03:00
parent 0f43ca0ce6
commit 241dea63c9
No known key found for this signature in database
GPG Key ID: 8C6CFB2FFFE8F68A
3 changed files with 8 additions and 4 deletions

View File

@ -10,7 +10,7 @@ import publishIsConfiguredInjectable from "../../main/application-update/publish
import type { AsyncFnMock } from "@async-fn/jest"; import type { AsyncFnMock } from "@async-fn/jest";
import asyncFn from "@async-fn/jest"; import asyncFn from "@async-fn/jest";
import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable"; import processCheckingForUpdatesInjectable from "../../main/application-update/check-for-updates/process-checking-for-updates.injectable";
import startCheckingForUpdatesInjectable from "../../main/application-update/periodical-check-for-updates/start-checking-for-updates.injectable"; import periodicalCheckForUpdatesInjectable from "../../main/application-update/periodical-check-for-updates/periodical-check-for-updates.injectable";
const ENOUGH_TIME = 1000 * 60 * 60 * 2; const ENOUGH_TIME = 1000 * 60 * 60 * 2;
@ -24,7 +24,8 @@ describe("periodical checking of updates", () => {
applicationBuilder = getApplicationBuilder(); applicationBuilder = getApplicationBuilder();
applicationBuilder.beforeApplicationStart(({ mainDi }) => { applicationBuilder.beforeApplicationStart(({ mainDi }) => {
mainDi.unoverride(startCheckingForUpdatesInjectable); mainDi.unoverride(periodicalCheckForUpdatesInjectable);
mainDi.permitSideEffects(periodicalCheckForUpdatesInjectable);
processCheckingForUpdatesMock = asyncFn(); processCheckingForUpdatesMock = asyncFn();

View File

@ -28,6 +28,8 @@ const periodicalCheckForUpdatesInjectable = getInjectable({
}; };
}); });
}, },
causesSideEffects: true,
}); });
export default periodicalCheckForUpdatesInjectable; export default periodicalCheckForUpdatesInjectable;

View File

@ -84,9 +84,10 @@ import setUpdateOnQuitInjectable from "./electron-app/features/set-update-on-qui
import downloadPlatformUpdateInjectable from "./application-update/download-platform-update/download-platform-update.injectable"; import downloadPlatformUpdateInjectable from "./application-update/download-platform-update/download-platform-update.injectable";
import startCatalogSyncInjectable from "./catalog-sync-to-renderer/start-catalog-sync.injectable"; import startCatalogSyncInjectable from "./catalog-sync-to-renderer/start-catalog-sync.injectable";
import startKubeConfigSyncInjectable from "./start-main-application/runnables/kube-config-sync/start-kube-config-sync.injectable"; import startKubeConfigSyncInjectable from "./start-main-application/runnables/kube-config-sync/start-kube-config-sync.injectable";
import startCheckingForUpdatesInjectable from "./application-update/periodical-check-for-updates/start-checking-for-updates.injectable";
import appVersionInjectable from "../common/get-configuration-file-model/app-version/app-version.injectable"; import appVersionInjectable from "../common/get-configuration-file-model/app-version/app-version.injectable";
import getRandomIdInjectable from "../common/utils/get-random-id.injectable"; import getRandomIdInjectable from "../common/utils/get-random-id.injectable";
import periodicalCheckForUpdatesInjectable
from "./application-update/periodical-check-for-updates/periodical-check-for-updates.injectable";
export function getDiForUnitTesting(opts: GetDiForUnitTestingOptions = {}) { export function getDiForUnitTesting(opts: GetDiForUnitTestingOptions = {}) {
const { const {
@ -135,7 +136,7 @@ export function getDiForUnitTesting(opts: GetDiForUnitTestingOptions = {}) {
di.override(applicationMenuInjectable, () => ({ start: () => {}, stop: () => {} })); di.override(applicationMenuInjectable, () => ({ start: () => {}, stop: () => {} }));
di.override(startCheckingForUpdatesInjectable, () => ({ run: () => {} })); di.override(periodicalCheckForUpdatesInjectable, () => ({ start: () => {}, stop: () => {}, started: false }));
// TODO: Remove usages of globally exported appEventBus to get rid of this // TODO: Remove usages of globally exported appEventBus to get rid of this
di.override(appEventBusInjectable, () => new EventEmitter<[AppEvent]>()); di.override(appEventBusInjectable, () => new EventEmitter<[AppEvent]>());