UNPKG

one

Version:

One is a new React Framework that makes Vite serve both native and web.

68 lines (67 loc) 2.36 kB
import { describe, expect, it, vi } from "vitest"; import { StackToolbar } from "../StackToolbar.mjs"; import { STACK_TOOLBAR_CHILD } from "../StackToolbarImplementation.mjs"; import { exposeStackToolbarConfig } from "../StackToolbar.shared.mjs"; import { appendScreenStackPropsToOptions } from "../StackScreen.mjs"; import { jsx } from "react/jsx-runtime"; describe("Stack.Toolbar headless config", () => { it("marks declaration children for installed implementations", () => { expect(StackToolbar.Button[STACK_TOOLBAR_CHILD]).toBe("button"); expect(StackToolbar.MenuAction[STACK_TOOLBAR_CHILD]).toBe("menuAction"); }); it("preserves every placement for the headless stack implementation", () => { const options = appendScreenStackPropsToOptions({ title: "Inbox" }, { children: [/* @__PURE__ */jsx(StackToolbar, { placement: "left", children: /* @__PURE__ */jsx(StackToolbar.Button, { icon: "sidebar.left" }) }, "left"), /* @__PURE__ */jsx(StackToolbar, { placement: "right", children: /* @__PURE__ */jsx(StackToolbar.Button, { icon: "square.and.arrow.up" }) }, "right")] }); expect(exposeStackToolbarConfig(options)).toMatchObject({ title: "Inbox", toolbar: { left: { placement: "left" }, right: { placement: "right" } } }); }); it("hands toolbar declarations to an installed implementation", () => { const appendPropsToOptions = vi.fn(options2 => ({ ...options2, headerShown: true })); const implementation = { appendPropsToOptions, render: () => null }; const toolbar = /* @__PURE__ */jsx(StackToolbar, { placement: "right", children: /* @__PURE__ */jsx(StackToolbar.Button, { icon: "square.and.arrow.up", children: "Share" }) }); const options = appendScreenStackPropsToOptions({ title: "Inbox" }, { children: toolbar }, implementation); expect(options.headerShown).toBe(true); expect(appendPropsToOptions).toHaveBeenCalledOnce(); expect(appendPropsToOptions.mock.calls[0]?.[1]).toBe(toolbar.props); expect(exposeStackToolbarConfig(options).toolbar.right).toBe(toolbar.props); }); }); //# sourceMappingURL=StackToolbar.test.mjs.map