Simplify test setup by removing option for global overrides (#7302)

* Remove option to doGeneralOverrides and do it always

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Override telemetry by default to optimize and simplify testing

Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Simplify more usages of getDiForUnitTesting

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

* Fix code style

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>

---------

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
This commit is contained in:
Janne SavolainenandMikko Aspiala authored and GitHub committed 2023-03-07 12:23:57 -05:00
1 parent 8fa92c06ea
commit 0d480917cf
95 files changed
+165 -161

No files matched your search

@@ -23,6 +23,8 @@ describe("check-for-platform-updates", () => {
beforeEach(() => {
const di = getDiForUnitTesting();
di.unoverride(checkForPlatformUpdatesInjectable);
checkForUpdatesMock = asyncFn();
electronUpdaterFake = {
@@ -26,6 +26,8 @@ describe("download-platform-update", () => {
beforeEach(() => {
di = getDiForUnitTesting();
di.unoverride(downloadPlatformUpdateInjectable);
downloadUpdateMock = asyncFn();
electronUpdaterOnMock = jest.fn();
electronUpdaterOffMock = jest.fn();
@@ -37,9 +37,7 @@ describe("computeUnixShellEnvironment technical tests", () => {
let unixShellEnv: ReturnType<ComputeUnixShellEnvironment>;
beforeEach(() => {
di = getDiForUnitTesting({
doGeneralOverrides: true,
});
di = getDiForUnitTesting();
spawnMock = jest.fn().mockImplementation((spawnfile, spawnargs) => {
shellStdin = new MemoryStream();
@@ -9,12 +9,15 @@ import { getDiForUnitTesting } from "../../renderer/getDiForUnitTesting";
import telemetryWhiteListForFunctionsInjectable from "./renderer/telemetry-white-list-for-functions.injectable";
import emitEventInjectable from "../../common/app-event-bus/emit-event.injectable";
import logErrorInjectable from "../../common/log-error.injectable";
import telemetryDecoratorInjectable from "./renderer/telemetry-decorator.injectable";
describe("emit-telemetry-from-specific-function-calls", () => {
let di: DiContainer;
beforeEach(() => {
di = getDiForUnitTesting({ doGeneralOverrides: true });
di = getDiForUnitTesting();
di.unoverride(telemetryDecoratorInjectable);
});
describe("given a telemetry white-list for injectables which instantiate a function", () => {
@@ -0,0 +1,11 @@
/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import { identity } from "lodash/fp";
import { getGlobalOverride } from "../../../common/test-utils/get-global-override";
import telemetryDecoratorInjectable from "./telemetry-decorator.injectable";
export default getGlobalOverride(telemetryDecoratorInjectable, () => ({
decorate: identity,
}));