mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
/**
|
|
* Copyright (c) OpenLens Authors. All rights reserved.
|
|
* Licensed under MIT License. See LICENSE in root directory for more information.
|
|
*/
|
|
import electronAppInjectable from "../../electron-app/electron-app.injectable";
|
|
import getElectronAppPathInjectable from "./get-electron-app-path.injectable";
|
|
import { getDiForUnitTesting } from "../../getDiForUnitTesting";
|
|
import type { App } from "electron";
|
|
import joinPathsInjectable from "../../../common/path/join-paths.injectable";
|
|
import { joinPathsFake } from "../../../common/test-utils/join-paths-fake";
|
|
|
|
describe("get-electron-app-path", () => {
|
|
let getElectronAppPath: (name: string) => string;
|
|
|
|
beforeEach(() => {
|
|
const di = getDiForUnitTesting({ doGeneralOverrides: false });
|
|
|
|
const appStub = {
|
|
name: "some-app-name",
|
|
|
|
getPath: (name: string) => {
|
|
if (name !== "some-existing-name") {
|
|
throw new Error("irrelevant");
|
|
}
|
|
|
|
return "some-existing-app-path";
|
|
},
|
|
|
|
// eslint-disable-next-line unused-imports/no-unused-vars-ts
|
|
setPath: (_, __) => undefined,
|
|
} as App;
|
|
|
|
di.override(electronAppInjectable, () => appStub);
|
|
di.override(joinPathsInjectable, () => joinPathsFake);
|
|
|
|
getElectronAppPath = di.inject(getElectronAppPathInjectable) as (name: string) => string;
|
|
});
|
|
|
|
it("given app path exists, when called, returns app path", () => {
|
|
const actual = getElectronAppPath("some-existing-name");
|
|
|
|
expect(actual).toBe("some-existing-app-path");
|
|
});
|
|
|
|
it("given app path does not exist, when called, returns null", () => {
|
|
const actual = getElectronAppPath("some-non-existing-name");
|
|
|
|
expect(actual).toBe("");
|
|
});
|
|
});
|