1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/packages/technical-features/application/electron-main/src/start-application/when-app-is-ready.test.ts
Janne Savolainen 699fc0309e
Introduce eslint and prettier for features and start using it (#7306)
* Introduce package for sharing eslint and prettier configurations

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

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

* Start using eslint and prettier in packages

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

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

---------

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2023-03-10 12:25:04 +02:00

48 lines
1.4 KiB
TypeScript

import { createContainer, DiContainer } from "@ogre-tools/injectable";
import { applicationFeatureForElectronMain } from "../feature";
import { registerFeature } from "@k8slens/feature-core";
import whenAppIsReadyInjectable from "./when-app-is-ready.injectable";
import { getPromiseStatus } from "@ogre-tools/test-utils";
import electronAppInjectable from "../electron/electron-app.injectable";
import type { AsyncFnMock } from "@async-fn/jest";
import asyncFn from "@async-fn/jest";
describe("when-app-is-ready", () => {
let di: DiContainer;
let whenReadyMock: AsyncFnMock<() => Promise<void>>;
beforeEach(() => {
di = createContainer("irrelevant");
registerFeature(di, applicationFeatureForElectronMain);
whenReadyMock = asyncFn();
di.override(electronAppInjectable, () => ({ whenReady: whenReadyMock } as unknown));
});
describe("when called", () => {
let actualPromise: Promise<void>;
beforeEach(() => {
const whenAppIsReady = di.inject(whenAppIsReadyInjectable);
actualPromise = whenAppIsReady();
});
it("does not resolve yet", async () => {
const promiseStatus = await getPromiseStatus(actualPromise);
expect(promiseStatus.fulfilled).toBe(false);
});
it("when app is ready, resolves", async () => {
await whenReadyMock.resolve();
const promiseStatus = await getPromiseStatus(actualPromise);
expect(promiseStatus.fulfilled).toBe(true);
});
});
});