From 672e96ee646bf53df580a2e80ac170013bc4e437 Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Tue, 12 Apr 2022 08:27:19 +0300 Subject: [PATCH] Override dependency for causing side effects Co-authored-by: Mikko Aspiala Signed-off-by: Janne Savolainen --- src/main/getDiForUnitTesting.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/getDiForUnitTesting.ts b/src/main/getDiForUnitTesting.ts index 514e4eeb7c..8c6633c9b8 100644 --- a/src/main/getDiForUnitTesting.ts +++ b/src/main/getDiForUnitTesting.ts @@ -44,6 +44,9 @@ import exitAppInjectable from "./electron-app/exit-app.injectable"; import setApplicationNameInjectable from "./electron-app/set-application-name.injectable"; import getCommandLineSwitchInjectable from "./electron-app/get-command-line-switch.injectable"; import isAutoUpdateEnabledInjectable from "./is-auto-update-enabled.injectable"; +import appEventBusInjectable from "../common/app-event-bus/app-event-bus.injectable"; +import { EventEmitter } from "../common/event-emitter"; +import type { AppEvent } from "../common/app-event-bus/event-bus"; export const getDiForUnitTesting = ( { doGeneralOverrides } = { doGeneralOverrides: false }, @@ -82,6 +85,9 @@ export const getDiForUnitTesting = ( di.override(getCommandLineSwitchInjectable, () => () => "irrelevant"); di.override(isAutoUpdateEnabledInjectable, () => () => false); + // TODO: Remove usages of globally exported appEventBus to get rid of this + di.override(appEventBusInjectable, () => new EventEmitter<[AppEvent]>()); + // eslint-disable-next-line unused-imports/no-unused-vars-ts di.override(extensionsStoreInjectable, () => ({ isEnabled: ({ id, isBundled }) => false }) as ExtensionsStore);