mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Consolidate output of get-composite-path to match find-composite's input
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi> Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
This commit is contained in:
parent
20aaaafce3
commit
1eb45ac1a4
@ -51,11 +51,11 @@ describe("get-composite-paths", () => {
|
|||||||
const actual = getCompositePaths(composite);
|
const actual = getCompositePaths(composite);
|
||||||
|
|
||||||
expect(actual).toEqual([
|
expect(actual).toEqual([
|
||||||
"some-root-id",
|
["some-root-id"],
|
||||||
"some-root-id -> some-child-id-1",
|
["some-root-id", "some-child-id-1"],
|
||||||
"some-root-id -> some-child-id-1 -> some-grandchild-id-1",
|
["some-root-id", "some-child-id-1", "some-grandchild-id-1"],
|
||||||
"some-root-id -> some-child-id-1 -> some-grandchild-id-2",
|
["some-root-id", "some-child-id-1", "some-grandchild-id-2"],
|
||||||
"some-root-id -> some-child-id-2",
|
["some-root-id", "some-child-id-2"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -9,4 +9,4 @@ import { getCompositeNormalization } from "../get-composite-normalization/get-co
|
|||||||
|
|
||||||
export const getCompositePaths = (
|
export const getCompositePaths = (
|
||||||
composite: Composite<unknown>,
|
composite: Composite<unknown>,
|
||||||
): string[] => pipeline(composite, getCompositeNormalization, map(([path]) => path.join(" -> ")));
|
): string[][] => pipeline(composite, getCompositeNormalization, map(([path]) => path));
|
||||||
|
|||||||
@ -224,7 +224,7 @@ Available parent ids are:
|
|||||||
it("creates composite without the orphan item, and without throwing", () => {
|
it("creates composite without the orphan item, and without throwing", () => {
|
||||||
const paths = getCompositePaths(composite);
|
const paths = getCompositePaths(composite);
|
||||||
|
|
||||||
expect(paths).toEqual(["some-root-id"]);
|
expect(paths).toEqual([["some-root-id"]]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("handles the missing parent ids", () => {
|
it("handles the missing parent ids", () => {
|
||||||
@ -379,11 +379,11 @@ Available parent ids are:
|
|||||||
const orderedPaths = getCompositePaths(composite);
|
const orderedPaths = getCompositePaths(composite);
|
||||||
|
|
||||||
expect(orderedPaths).toEqual([
|
expect(orderedPaths).toEqual([
|
||||||
"some-root-id",
|
["some-root-id"],
|
||||||
"some-root-id -> some-id-1",
|
["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-1"],
|
||||||
"some-root-id -> some-id-1 -> some-child-id-2",
|
["some-root-id", "some-id-1", "some-child-id-2"],
|
||||||
"some-root-id -> some-id-2",
|
["some-root-id", "some-id-2"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -435,11 +435,11 @@ Available parent ids are:
|
|||||||
const orderedPaths = getCompositePaths(composite);
|
const orderedPaths = getCompositePaths(composite);
|
||||||
|
|
||||||
expect(orderedPaths).toEqual([
|
expect(orderedPaths).toEqual([
|
||||||
"some-root-id",
|
["some-root-id"],
|
||||||
"some-root-id -> some-id-1",
|
["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-1"],
|
||||||
"some-root-id -> some-id-1 -> some-child-id-2",
|
["some-root-id", "some-id-1", "some-child-id-2"],
|
||||||
"some-root-id -> some-id-2",
|
["some-root-id", "some-id-2"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -92,16 +92,16 @@ describe("application-menu-in-legacy-extension-api", () => {
|
|||||||
it("related menu items exist", () => {
|
it("related menu items exist", () => {
|
||||||
const menuItemPathsForExtension = builder.applicationMenu.items.filter(
|
const menuItemPathsForExtension = builder.applicationMenu.items.filter(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.startsWith("root -> some-top-menu-item -> some-extension-name"),
|
x.join(".").startsWith("root.some-top-menu-item.some-extension-name"),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(menuItemPathsForExtension).toEqual([
|
expect(menuItemPathsForExtension).toEqual([
|
||||||
"root -> some-top-menu-item -> some-extension-name/some-clickable-item",
|
["root", "some-top-menu-item", "some-extension-name/some-clickable-item"],
|
||||||
// Note: anonymous index "1" is used by the non-visible menu item.
|
// Note: anonymous index "1" is used by the non-visible menu item.
|
||||||
"root -> some-top-menu-item -> some-extension-name/2-separator",
|
["root", "some-top-menu-item", "some-extension-name/2-separator"],
|
||||||
"root -> some-top-menu-item -> some-extension-name/some-os-action-menu-item-id",
|
["root", "some-top-menu-item", "some-extension-name/some-os-action-menu-item-id"],
|
||||||
"root -> some-top-menu-item -> some-extension-name/some-submenu-with-explicit-children",
|
["root", "some-top-menu-item", "some-extension-name/some-submenu-with-explicit-children"],
|
||||||
"root -> some-top-menu-item -> some-extension-name/some-submenu-with-explicit-children -> some-extension-name/some-submenu-with-explicit-children/some-explicit-child",
|
["root", "some-top-menu-item", "some-extension-name/some-submenu-with-explicit-children", "some-extension-name/some-submenu-with-explicit-children/some-explicit-child"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ describe("application-menu-in-legacy-extension-api", () => {
|
|||||||
it("when related menu items no longer exist", () => {
|
it("when related menu items no longer exist", () => {
|
||||||
const menuItemPathsForExtension = builder.applicationMenu.items.filter(
|
const menuItemPathsForExtension = builder.applicationMenu.items.filter(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.startsWith("root.some-top-menu-item.some-extension-name"),
|
x.join(".").startsWith("root.some-top-menu-item.some-extension-name"),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(menuItemPathsForExtension).toEqual([]);
|
expect(menuItemPathsForExtension).toEqual([]);
|
||||||
@ -132,15 +132,15 @@ describe("application-menu-in-legacy-extension-api", () => {
|
|||||||
|
|
||||||
const menuItemPathsForExtension = builder.applicationMenu.items.filter(
|
const menuItemPathsForExtension = builder.applicationMenu.items.filter(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.startsWith("root -> some-top-menu-item -> some-extension-name"),
|
x.join(".").startsWith("root.some-top-menu-item.some-extension-name"),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(menuItemPathsForExtension).toEqual([
|
expect(menuItemPathsForExtension).toEqual([
|
||||||
"root -> some-top-menu-item -> some-extension-name/some-clickable-item",
|
["root", "some-top-menu-item", "some-extension-name/some-clickable-item"],
|
||||||
"root -> some-top-menu-item -> some-extension-name/2-separator",
|
["root", "some-top-menu-item", "some-extension-name/2-separator"],
|
||||||
"root -> some-top-menu-item -> some-extension-name/some-os-action-menu-item-id",
|
["root", "some-top-menu-item", "some-extension-name/some-os-action-menu-item-id"],
|
||||||
"root -> some-top-menu-item -> some-extension-name/some-submenu-with-explicit-children",
|
["root", "some-top-menu-item", "some-extension-name/some-submenu-with-explicit-children"],
|
||||||
"root -> some-top-menu-item -> some-extension-name/some-submenu-with-explicit-children -> some-extension-name/some-submenu-with-explicit-children/some-explicit-child",
|
["root", "some-top-menu-item", "some-extension-name/some-submenu-with-explicit-children", "some-extension-name/some-submenu-with-explicit-children/some-explicit-child"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -180,11 +180,11 @@ describe("application-menu-in-legacy-extension-api", () => {
|
|||||||
it("only recognizable menu items from extension exist", () => {
|
it("only recognizable menu items from extension exist", () => {
|
||||||
const menuItemPathsForExtension = builder.applicationMenu.items.filter(
|
const menuItemPathsForExtension = builder.applicationMenu.items.filter(
|
||||||
(x) =>
|
(x) =>
|
||||||
x.startsWith("root -> some-top-menu-item -> some-extension-name"),
|
x.join(".").startsWith("root.some-top-menu-item.some-extension-name"),
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(menuItemPathsForExtension).toEqual([
|
expect(menuItemPathsForExtension).toEqual([
|
||||||
"root -> some-top-menu-item -> some-extension-name/some-recognizable-item",
|
["root", "some-top-menu-item", "some-extension-name/some-recognizable-item"],
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@ -36,7 +36,7 @@ describe("application-menu", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("given enough time passes", () => {
|
describe("given enough time passes", () => {
|
||||||
let applicationMenuPaths: string[];
|
let applicationMenuPaths: string[][];
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
advanceFakeTime(100);
|
advanceFakeTime(100);
|
||||||
|
|||||||
@ -57,7 +57,7 @@ describe("handling-of-orphan-application-menu-items, given orphan menu item", ()
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("given some time passes", () => {
|
describe("given some time passes", () => {
|
||||||
let applicationMenuPaths: string[];
|
let applicationMenuPaths: string[][];
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
advanceFakeTime(100);
|
advanceFakeTime(100);
|
||||||
@ -72,7 +72,7 @@ describe("handling-of-orphan-application-menu-items, given orphan menu item", ()
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("does not show orphan application menu item", () => {
|
it("does not show orphan application menu item", () => {
|
||||||
expect(applicationMenuPaths.find(x => x.endsWith("some-item-id")));
|
expect(applicationMenuPaths.find(x => x.join(".").endsWith("some-item-id")));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("logs about bad menu item", () => {
|
it("logs about bad menu item", () => {
|
||||||
|
|||||||
@ -127,7 +127,7 @@ export interface ApplicationBuilder {
|
|||||||
|
|
||||||
applicationMenu: {
|
applicationMenu: {
|
||||||
click: (...path: string[]) => void;
|
click: (...path: string[]) => void;
|
||||||
items: string[];
|
items: string[][];
|
||||||
};
|
};
|
||||||
preferences: {
|
preferences: {
|
||||||
close: () => void;
|
close: () => void;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user