1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/src/features/application-menu/main/menu-items/composite/get-composite-paths/get-composite-paths.test.ts
Janne Savolainen f212c2a86d
Consolidate directory structure of composite
Co-authored-by: Mikko Aspiala <mikko.aspiala@gmail.com>

Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2022-10-21 08:23:21 +03:00

62 lines
1.4 KiB
TypeScript

/**
* Copyright (c) OpenLens Authors. All rights reserved.
* Licensed under MIT License. See LICENSE in root directory for more information.
*/
import getComposite from "../get-composite/get-composite";
import { getCompositePaths } from "./get-composite-paths";
describe("get-composite-paths", () => {
it("given composite with ordered children, returns ordered paths", () => {
const someRootItem = {
id: "some-root-id",
};
const someItem1 = {
id: "some-id-1",
parentId: "some-root-id",
orderNumber: 1,
};
const someItem2 = {
id: "some-id-2",
parentId: "some-root-id",
orderNumber: 2,
};
const someChildItem1 = {
id: "some-child-id-1",
parentId: "some-id-1",
orderNumber: 1,
};
const someChildItem2 = {
id: "some-child-id-2",
parentId: "some-id-1",
orderNumber: 2,
};
const items = [
someRootItem,
// Note: not in order yet.
someItem2,
someItem1,
someChildItem2,
someChildItem1,
];
const composite = getComposite({
source: items,
});
const actual = getCompositePaths(composite);
expect(actual).toEqual([
"some-root-id",
"some-root-id.some-id-1",
"some-root-id.some-id-1.some-child-id-1",
"some-root-id.some-id-1.some-child-id-2",
"some-root-id.some-id-2",
]);
});
});