Files
simple-react-app-kit/packages/blocks/src/lib/command-actions.test.tsx
T
Maofeng 011e7d8115 feat(blocks): add reusable application shell blocks
- add appearance state, theme presets, preference controls, and preview components

- add responsive primary, nested, mobile, and flyout navigation with route-aware breadcrumbs

- add application layout, sidebar state, header actions, user menu, query refresh, and scroll utilities

- add configurable chat and notification surfaces backed by consumer-provided data and queries

- expose package entry points and cover theme, state, and command behavior with tests
2026-07-29 21:22:47 +08:00

36 lines
1007 B
TypeScript

// @vitest-environment jsdom
import { fireEvent, render } from "@testing-library/react"
import { describe, expect, it, vi } from "vitest"
import {
getNavigationCommandProps,
NavigationActionTarget,
navigationActions,
} from "./command-actions"
describe("navigation command", () => {
it("connects an action button to its command target", () => {
expect(getNavigationCommandProps(navigationActions.search)).toEqual({
command: "--invoke",
commandfor: "navigation-action-search",
})
})
it("invokes the matching command target", () => {
const onInvoke = vi.fn()
const { container } = render(
<NavigationActionTarget
action={navigationActions.search}
onInvoke={onInvoke}
/>
)
const target = container.querySelector("#navigation-action-search")
const event = new Event("command")
Object.defineProperty(event, "command", { value: "--invoke" })
fireEvent(target!, event)
expect(onInvoke).toHaveBeenCalledOnce()
})
})