The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import type { MenuAction } from "@react-native-menu/menu"; |
| 2 | import { describe, expect, it, vi } from "vite-plus/test"; |
| 3 | |
| 4 | import { |
| 5 | appBarMenuItemsFromActions, |
| 6 | findAppBarMenuItem, |
| 7 | menuActionsFromAppBarItems, |
| 8 | } from "./menuActionItems"; |
| 9 | |
| 10 | describe("appBarMenuItemsFromActions", () => { |
| 11 | it("round-trips a filter menu through AppBar items back to menu actions", () => { |
| 12 | const actions: MenuAction[] = [ |
| 13 | { |
| 14 | id: "labels", |
| 15 | title: "Labels", |
| 16 | subactions: [ |
| 17 | { |
| 18 | id: "label:bug", |
| 19 | title: "bug", |
| 20 | image: "circle.fill", |
| 21 | imageColor: "#d73a4a", |
| 22 | state: "on", |
| 23 | }, |
| 24 | { id: "label:docs", title: "docs", subtitle: "3 open", state: "off" }, |
| 25 | ], |
| 26 | }, |
| 27 | ]; |
| 28 | const onSelect = vi.fn(); |
| 29 | |
| 30 | const items = appBarMenuItemsFromActions(actions, onSelect); |
| 31 | |
| 32 | expect(menuActionsFromAppBarItems(items)).toEqual([ |
| 33 | { |
| 34 | id: "labels", |
| 35 | title: "Labels", |
| 36 | image: undefined, |
| 37 | subactions: [ |
| 38 | { |
| 39 | id: "label:bug", |
| 40 | title: "bug", |
| 41 | subtitle: undefined, |
| 42 | image: "circle.fill", |
| 43 | imageColor: "#d73a4a", |
| 44 | state: "on", |
| 45 | attributes: undefined, |
| 46 | }, |
| 47 | { |
| 48 | id: "label:docs", |
| 49 | title: "docs", |
| 50 | subtitle: "3 open", |
| 51 | image: undefined, |
| 52 | imageColor: undefined, |
| 53 | state: undefined, |
| 54 | attributes: undefined, |
| 55 | }, |
| 56 | ], |
| 57 | }, |
| 58 | ]); |
| 59 | findAppBarMenuItem(items, "label:docs")?.onPress(); |
| 60 | expect(onSelect).toHaveBeenCalledWith("label:docs"); |
| 61 | expect( |
| 62 | menuActionsFromAppBarItems([{ id: "devices", title: "Devices", inline: true, items: [] }]), |
| 63 | ).toMatchObject([{ id: "devices", title: "Devices", displayInline: true }]); |
| 64 | }); |
| 65 | }); |