Files
Jarvis/webview/packages/hud/tests/setup.ts
james.maesandClaude Opus 4.7 b9755b14aa test(03-02): vitest coverage for @jarvis/hud store + bus dispatcher (12 tests)
- store.test.ts (6 tests): defaults, actions present, setHudState isolation
  (chatEvents ref stable), subscribeWithSelector granularity (hudState selector
  doesn't fire on chatEvents change), appendTokenToLastText no-op on unknown id +
  happy-path append.
- bus-dispatch.test.ts (6 tests): hudState outbound routes to store.setHudState;
  state transitions (listening -> idle); decode errors surface via console.error
  for invalid JSON and missing-discriminator; main.tsx boot posts uiReady after
  React commit; exhaustiveness-sentinel compile-time documentation test.
- setup.ts: ResizeObserver polyfill for jsdom — R3F <Canvas> via react-use-measure
  needs it, jsdom doesn't ship it.

Probe documented in SUMMARY (no commit): locally appending a synthetic
BusOutbound variant produces TS2322 on `_exhaustive: never = msg`, confirming
the guard is live.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-04-23 18:58:23 -05:00

20 lines
522 B
TypeScript

import '@testing-library/jest-dom'
// jsdom lacks ResizeObserver; R3F's <Canvas> uses react-use-measure which
// requires it. Install a no-op polyfill for tests.
if (typeof globalThis.ResizeObserver === 'undefined') {
class ResizeObserverPolyfill {
observe(): void {
/* noop */
}
unobserve(): void {
/* noop */
}
disconnect(): void {
/* noop */
}
}
;(globalThis as unknown as { ResizeObserver: typeof ResizeObserverPolyfill }).ResizeObserver =
ResizeObserverPolyfill
}