Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import { flattenInlineMenuSections } from "./android-menu-sections";
4
5describe("flattenInlineMenuSections", () => {
6 it("flattens inline groups and places a divider before each group", () => {
7 const entries = flattenInlineMenuSections([
8 { id: "settle", title: "Settle" },
9 {
10 id: "title-actions",
11 title: "",
12 displayInline: true,
13 subactions: [
14 { id: "rename", title: "Rename" },
15 { id: "regenerate", title: "Regenerate" },
16 ],
17 },
18 { id: "copy", title: "Copy" },
19 {
20 id: "delete-actions",
21 title: "",
22 displayInline: true,
23 subactions: [{ id: "delete", title: "Delete" }],
24 },
25 ]);
26
27 expect(entries.map(({ action }) => action.id)).toEqual([
28 "settle",
29 "rename",
30 "regenerate",
31 "copy",
32 "delete",
33 ]);
34 expect(entries.map(({ dividerBefore }) => dividerBefore)).toEqual([
35 false,
36 true,
37 false,
38 true,
39 true,
40 ]);
41 });
42
43 it("keeps regular submenus nested", () => {
44 const snooze = {
45 id: "snooze",
46 title: "Snooze",
47 subactions: [{ id: "tomorrow", title: "Tomorrow" }],
48 };
49 expect(flattenInlineMenuSections([snooze])).toEqual([{ action: snooze, dividerBefore: false }]);
50 });
51});