Open History to see the last commit
1import type { MenuAction } from "@react-native-menu/menu";
2import { describe, expect, it, vi } from "vite-plus/test";
3
4import { androidHeaderMenuActions, findHeaderMenuAction } from "./headerMenu.android";
5import { appBarMenuItemsFromActions } from "./menuActionItems";
6
7describe("appBarMenuItemsFromActions", () => {
8 it("round-trips a filter menu through AppBar items back to Android actions", () => {
9 const actions: MenuAction[] = [
10 {
11 id: "labels",
12 title: "Labels",
13 subactions: [
14 {
15 id: "label:bug",
16 title: "bug",
17 image: "circle.fill",
18 imageColor: "#d73a4a",
19 state: "on",
20 },
21 { id: "label:docs", title: "docs", subtitle: "3 open", state: "off" },
22 ],
23 },
24 ];
25 const onSelect = vi.fn();
26
27 const items = appBarMenuItemsFromActions(actions, onSelect);
28
29 expect(androidHeaderMenuActions(items)).toEqual([
30 {
31 id: "labels",
32 title: "Labels",
33 image: undefined,
34 subactions: [
35 {
36 id: "label:bug",
37 title: "bug",
38 subtitle: undefined,
39 image: "circle.fill",
40 imageColor: "#d73a4a",
41 state: "on",
42 attributes: undefined,
43 },
44 {
45 id: "label:docs",
46 title: "docs",
47 subtitle: "3 open",
48 image: undefined,
49 imageColor: undefined,
50 state: undefined,
51 attributes: undefined,
52 },
53 ],
54 },
55 ]);
56 findHeaderMenuAction(items, "label:docs")?.onPress();
57 expect(onSelect).toHaveBeenCalledWith("label:docs");
58 });
59});