mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
override logger with mocks only when needed for tests
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
f2a0b72253
commit
9d4b6c52c0
@ -89,7 +89,15 @@ describe("HotbarStore", () => {
|
|||||||
|
|
||||||
di.override(hasCategoryForEntityInjectable, () => () => true);
|
di.override(hasCategoryForEntityInjectable, () => () => true);
|
||||||
|
|
||||||
logger = di.inject(loggerInjectable) as jest.Mocked<Logger>;
|
logger = {
|
||||||
|
warn: jest.fn(),
|
||||||
|
debug: jest.fn(),
|
||||||
|
error: jest.fn(),
|
||||||
|
info: jest.fn(),
|
||||||
|
silly: jest.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
di.override(loggerInjectable, () => logger);
|
||||||
|
|
||||||
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
|
const catalogEntityRegistry = di.inject(catalogEntityRegistryInjectable);
|
||||||
const catalogCatalogEntity = di.inject(catalogCatalogEntityInjectable);
|
const catalogCatalogEntity = di.inject(catalogCatalogEntityInjectable);
|
||||||
|
|||||||
@ -33,7 +33,16 @@ describe("kubeconfig manager tests", () => {
|
|||||||
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
di = getDiForUnitTesting({ doGeneralOverrides: true });
|
||||||
|
|
||||||
di.override(directoryForTempInjectable, () => "some-directory-for-temp");
|
di.override(directoryForTempInjectable, () => "some-directory-for-temp");
|
||||||
logger = di.inject(loggerInjectable) as jest.Mocked<Logger>;
|
|
||||||
|
logger = {
|
||||||
|
warn: jest.fn(),
|
||||||
|
debug: jest.fn(),
|
||||||
|
error: jest.fn(),
|
||||||
|
info: jest.fn(),
|
||||||
|
silly: jest.fn(),
|
||||||
|
};
|
||||||
|
|
||||||
|
di.override(loggerInjectable, () => logger);
|
||||||
|
|
||||||
mockFs({
|
mockFs({
|
||||||
"minikube-config.yml": JSON.stringify({
|
"minikube-config.yml": JSON.stringify({
|
||||||
|
|||||||
@ -35,6 +35,7 @@ import joinPathsInjectable from "../common/path/join-paths.injectable";
|
|||||||
import { joinPathsFake } from "../common/test-utils/join-paths-fake";
|
import { joinPathsFake } from "../common/test-utils/join-paths-fake";
|
||||||
import hotbarStoreInjectable from "../common/hotbars/store.injectable";
|
import hotbarStoreInjectable from "../common/hotbars/store.injectable";
|
||||||
import type { GetDiForUnitTestingOptions } from "../test-utils/get-dis-for-unit-testing";
|
import type { GetDiForUnitTestingOptions } from "../test-utils/get-dis-for-unit-testing";
|
||||||
|
import { noop } from "../renderer/utils";
|
||||||
|
|
||||||
export interface GetMainDiForUnitTestingOptions extends GetDiForUnitTestingOptions {
|
export interface GetMainDiForUnitTestingOptions extends GetDiForUnitTestingOptions {
|
||||||
overrideHotbarStore?: boolean;
|
overrideHotbarStore?: boolean;
|
||||||
@ -130,11 +131,11 @@ export function getDiForUnitTesting(opts: GetMainDiForUnitTestingOptions = {}) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
di.override(loggerInjectable, () => ({
|
di.override(loggerInjectable, () => ({
|
||||||
warn: jest.fn(),
|
warn: noop,
|
||||||
debug: jest.fn(),
|
debug: noop,
|
||||||
error: jest.fn(),
|
error: noop,
|
||||||
info: jest.fn(),
|
info: noop,
|
||||||
silly: jest.fn(),
|
silly: noop,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -34,6 +34,7 @@ import terminalSpawningPoolInjectable from "./components/dock/terminal/terminal-
|
|||||||
import hostedClusterIdInjectable from "../common/cluster-store/hosted-cluster-id.injectable";
|
import hostedClusterIdInjectable from "../common/cluster-store/hosted-cluster-id.injectable";
|
||||||
import type { GetDiForUnitTestingOptions } from "../test-utils/get-dis-for-unit-testing";
|
import type { GetDiForUnitTestingOptions } from "../test-utils/get-dis-for-unit-testing";
|
||||||
import historyInjectable from "./navigation/history.injectable";
|
import historyInjectable from "./navigation/history.injectable";
|
||||||
|
import { noop } from "./utils";
|
||||||
|
|
||||||
export const getDiForUnitTesting = (opts: GetDiForUnitTestingOptions = {}) => {
|
export const getDiForUnitTesting = (opts: GetDiForUnitTestingOptions = {}) => {
|
||||||
const {
|
const {
|
||||||
@ -86,11 +87,11 @@ export const getDiForUnitTesting = (opts: GetDiForUnitTestingOptions = {}) => {
|
|||||||
di.override(focusWindowInjectable, () => () => {});
|
di.override(focusWindowInjectable, () => () => {});
|
||||||
|
|
||||||
di.override(loggerInjectable, () => ({
|
di.override(loggerInjectable, () => ({
|
||||||
warn: jest.fn(),
|
warn: noop,
|
||||||
debug: jest.fn(),
|
debug: noop,
|
||||||
error: jest.fn(),
|
error: noop,
|
||||||
info: jest.fn(),
|
info: noop,
|
||||||
silly: jest.fn(),
|
silly: noop,
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user