Files
dsh-context/tests/client/react.spec.ts
T
Bowen Liang f106b720ac test: rebuild the suite at source level with 100% per-file coverage gates
The old suite exercised the built lib/ bundle, so v8 remapped almost
nothing (8% src coverage) and every run needed a build first. The new
suite imports src/ directly under two vitest projects (node for
host/shared, jsdom for client), rendering real React 18 trees against
the real dictionaries and ui-primitives, with faithful in-memory
harness faces (cordis inject/effect, locale chain, slots, sessions
provide) instead of plugin mocks.

- 43 fine-grained, stateless, single-module spec files (606 tests)
  forked across workers: ~2.5s wall, no build step
- v8 thresholds at 100/100/100/100 per file over src/**
- host specs drive the real projection definitions (init/apply/view)
  plus one full cordis + SessionStore + SessionProjectionRegistry
  integration; the framework's snapshotJsonValue pins the
  projection-cache precondition on every intermediate fold state
- oxlint's src ruleset now covers tests/** as well
- typecheck covers the tests via tsconfig.tests.json
2026-08-26 00:58:39 +08:00

32 lines
1.1 KiB
TypeScript

// The platform React module table (src/client/react.ts): the plugin's React
// is the real react module, h creates elements, and ReactDOM exposes portals.
import assert from 'node:assert/strict'
import { createElement } from 'react'
import { describe, test } from 'vitest'
import { h, React, ReactDOM } from '../../src/client/react'
describe('react module table', () => {
test('React is the real react module', () => {
assert.equal(React.createElement, createElement)
})
test('h creates elements', () => {
// Viewed structurally: React's public types hide $$typeof and the
// children prop slot, but both are part of the real element shape.
const el = h('div', { className: 'box' }, 'hi') as unknown as {
$$typeof: symbol
type: unknown
props: Record<string, unknown>
}
assert.equal(el.$$typeof, Symbol.for('react.element'))
assert.equal(el.type, 'div')
assert.equal(el.props.className, 'box')
assert.equal(el.props.children, 'hi')
})
test('ReactDOM exposes createPortal', () => {
assert.equal(typeof ReactDOM.createPortal, 'function')
})
})