MCPcopy
hub / github.com/simstudioai/sim / renderSmoothText

Function renderSmoothText

apps/sim/hooks/use-smooth-text.test.tsx:20–46  ·  view source on GitHub ↗

* Minimal dependency-free hook harness (the repo has no `@testing-library/react`). Mounts the hook in * a real React root under jsdom so effects and refs run exactly as in the app. Fake timers keep the * paced reveal from advancing, so each assertion observes the synchronous reveal decision only.

(initial: ProbeProps)

Source from the content-addressed store, hash-verified

18 * paced reveal from advancing, so each assertion observes the synchronous reveal decision only.
19 */
20function renderSmoothText(initial: ProbeProps) {
21 ;(globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true
22 const container = document.createElement('div')
23 const root: Root = createRoot(container)
24 const props = { ...initial }
25 let latest = ''
26
27 function Probe(p: ProbeProps) {
28 latest = useSmoothText(p.content, p.isStreaming, { snapOnNonAppend: p.snapOnNonAppend })
29 return null
30 }
31
32 const render = () =>
33 act(() => {
34 root.render(<Probe {...props} />)
35 })
36 render()
37
38 return {
39 value: () => latest,
40 rerender: (next: Partial<ProbeProps>) => {
41 Object.assign(props, next)
42 render()
43 },
44 unmount: () => act(() => root.unmount()),
45 }
46}
47
48const LONG = `# Existing Document\n\n${'Lorem ipsum dolor sit amet, '.repeat(8)}`
49

Callers 1

Calls 2

unmountMethod · 0.80
renderFunction · 0.70

Tested by

no test coverage detected