1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/common/front-end-routing/verify-that-all-routes-have-route-component.test.ts
Jim Ehrismann a2d52fa6b8
Made welcome page configurable (#6232)
Co-authored-by: Sebastian Malton <sebastian@malton.name>
2022-09-14 09:07:44 -04:00

46 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 { getDiForUnitTesting } from "../../renderer/getDiForUnitTesting";
import { routeSpecificComponentInjectionToken } from "../../renderer/routes/route-specific-component-injection-token";
import { frontEndRouteInjectionToken } from "./front-end-route-injection-token";
import { filter, map } from "lodash/fp";
import clusterStoreInjectable from "../cluster-store/cluster-store.injectable";
import type { ClusterStore } from "../cluster-store/cluster-store";
import { pipeline } from "@ogre-tools/fp";
describe("verify-that-all-routes-have-component", () => {
it("verify that routes have route component", () => {
const rendererDi = getDiForUnitTesting({ doGeneralOverrides: true });
rendererDi.override(clusterStoreInjectable, () => ({
getById: () => null,
} as unknown as ClusterStore));
const routes = rendererDi.injectMany(frontEndRouteInjectionToken);
const routeComponents = rendererDi.injectMany(
routeSpecificComponentInjectionToken,
);
const routesMissingComponent = pipeline(
routes,
map(
(currentRoute) => ({
path: currentRoute.path,
routeComponent: routeComponents.find(({ route }) => (
route.path === currentRoute.path
&& route.clusterFrame === currentRoute.clusterFrame)),
}),
),
filter({ routeComponent: undefined }),
map("path"),
);
expect(routesMissingComponent).toEqual([]);
});
});