mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
* Add custom jest resolver to fix requiring "uuid" module Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Update dependencies Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Introduce test utils for rendering and running with thrown mobx reactions Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Extract startable-stoppable to NPM package Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Extract messaging to NPM package Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Switch to using startable-stoppable from NPM package Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Switch to using messaging from the Feature Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Remove old implementation of messaging Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Make setupping app paths happen earlier in renderer Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Fix typo Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add kludge to make testing-library work properly from test-utils package Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Fix code style Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add lint:fix -root script Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Fix unrelated failing unit tests Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Turn of no-floating-promises from typescript linting for being broken Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Make linting not happen for dist -directories Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Make linting failures appear as failure Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Stop running prettier twice It already gets ran as eslint-plugin. Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Make CI run unit tests for all packages by consolidating name of NPM script Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add missing unit tests for coverage Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Skip coverage for test utils Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Remove check for coverage in packages which are not ready for it Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Stop collecting coverage from index.ts files them being indirections to the implementation Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com> Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Implement sending message to channel in main Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add missing feature dependencies Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add dummy implementations for requesting in main from renderer Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Re-enable communicating from main to cluster frames Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Ignore trivial files from coverage Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Update package-lock Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Extract message-bridge to separate NPM package to prevent dev dependencies being in the production bundle Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Extract computed channel to own NPM package for clear dependencies Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Consolidate electron related stuff to a directory Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Add missing publish configurations Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> * Ignore test implementation from coverage being not interesting Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> --------- Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
98 lines
3.3 KiB
TypeScript
98 lines
3.3 KiB
TypeScript
import { createContainer, DiContainer, getInjectable } from "@ogre-tools/injectable";
|
|
import { registerFeature } from "@k8slens/feature-core";
|
|
import { applicationFeature } from "../feature";
|
|
import { startApplicationInjectionToken } from "./start-application.injectable";
|
|
import * as timeSlots from "./time-slots";
|
|
import asyncFn, { AsyncFnMock } from "@async-fn/jest";
|
|
import { getPromiseStatus } from "@k8slens/test-utils";
|
|
|
|
describe("starting-of-application", () => {
|
|
let di: DiContainer;
|
|
|
|
let beforeApplicationIsLoadingMock: AsyncFnMock<() => Promise<void>>;
|
|
let onLoadOfApplicationMock: AsyncFnMock<() => Promise<void>>;
|
|
let afterApplicationIsLoadedMock: AsyncFnMock<() => Promise<void>>;
|
|
|
|
beforeEach(() => {
|
|
di = createContainer("irrelevant");
|
|
|
|
registerFeature(di, applicationFeature);
|
|
|
|
beforeApplicationIsLoadingMock = asyncFn();
|
|
onLoadOfApplicationMock = asyncFn();
|
|
afterApplicationIsLoadedMock = asyncFn();
|
|
|
|
const beforeApplicationIsLoadingInjectable = getInjectable({
|
|
id: "before-application-is-loading",
|
|
instantiate: () => ({ run: beforeApplicationIsLoadingMock }),
|
|
injectionToken: timeSlots.beforeApplicationIsLoadingInjectionToken,
|
|
});
|
|
|
|
const onLoadOfApplicationInjectable = getInjectable({
|
|
id: "on-load-of-application",
|
|
instantiate: () => ({ run: onLoadOfApplicationMock }),
|
|
injectionToken: timeSlots.onLoadOfApplicationInjectionToken,
|
|
});
|
|
|
|
const afterApplicationIsLoadedInjectable = getInjectable({
|
|
id: "after-application-is-loaded",
|
|
instantiate: () => ({ run: afterApplicationIsLoadedMock }),
|
|
injectionToken: timeSlots.afterApplicationIsLoadedInjectionToken,
|
|
});
|
|
|
|
di.register(
|
|
beforeApplicationIsLoadingInjectable,
|
|
onLoadOfApplicationInjectable,
|
|
afterApplicationIsLoadedInjectable,
|
|
);
|
|
});
|
|
|
|
describe("when application is started", () => {
|
|
let actualPromise: Promise<void>;
|
|
|
|
beforeEach(() => {
|
|
const startApplication = di.inject(startApplicationInjectionToken);
|
|
|
|
actualPromise = startApplication();
|
|
});
|
|
|
|
it("calls runnables registered in before application is loading", () => {
|
|
expect(beforeApplicationIsLoadingMock).toHaveBeenCalled();
|
|
});
|
|
|
|
describe("when runnables in before application is loading resolve", () => {
|
|
beforeEach(async () => {
|
|
await beforeApplicationIsLoadingMock.resolve();
|
|
});
|
|
|
|
it("calls runnables registered in on load of application", () => {
|
|
expect(onLoadOfApplicationMock).toHaveBeenCalled();
|
|
});
|
|
|
|
describe("when runnables in before application is loading resolve", () => {
|
|
beforeEach(async () => {
|
|
await onLoadOfApplicationMock.resolve();
|
|
});
|
|
|
|
it("calls runnables registered in after load of application", async () => {
|
|
expect(afterApplicationIsLoadedMock).toHaveBeenCalled();
|
|
});
|
|
|
|
it("does not resolve yet", async () => {
|
|
const promiseStatus = await getPromiseStatus(actualPromise);
|
|
|
|
expect(promiseStatus.fulfilled).toBe(false);
|
|
});
|
|
|
|
it("when runnables in after application is loaded resolve, resolves", async () => {
|
|
await afterApplicationIsLoadedMock.resolve();
|
|
|
|
const promiseStatus = await getPromiseStatus(actualPromise);
|
|
|
|
expect(promiseStatus.fulfilled).toBe(true);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|