UNPKG

one

Version:

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

57 lines (56 loc) 1.48 kB
import TestRenderer, { act } from "react-test-renderer"; import { describe, expect, it } from "vitest"; import { appendStackToolbarConfig } from "../../layouts/stack-utils/StackToolbar.shared.mjs"; import { StackStateProvider, useStack } from "../useStack.mjs"; import { jsx } from "react/jsx-runtime"; describe("StackStateProvider", () => { it("hands toolbar config to headless implementations", () => { let options; function Capture() { options = useStack().focused.options; return null; } const state = { stale: false, type: "stack", key: "stack-key", index: 0, routeNames: ["index"], routes: [{ key: "index-key", name: "index" }], preloadedRoutes: [] }; const descriptors = { "index-key": { options: appendStackToolbarConfig({ title: "Inbox" }, { placement: "right", children: "Share" }), render: () => /* @__PURE__ */jsx("div", { children: "Inbox" }) } }; act(() => { TestRenderer.create(/* @__PURE__ */jsx(StackStateProvider, { state, descriptors, children: /* @__PURE__ */jsx(Capture, {}) })); }); expect(options).toMatchObject({ title: "Inbox", toolbar: { right: { placement: "right", children: "Share" } } }); }); }); //# sourceMappingURL=useStack.test.mjs.map