Production-ready animations, transitions, backgrounds, and scenes for Remotion
radio — verification tests
Pure / deterministic verification for the radio component
(registry/remocn-ui/radio/). The RENDER path needs Remotion's
useCurrentFrame() and cannot run headless, so the render is NOT exercised
here. This suite covers the pieces that ARE pure: RadioState union
membership, radioConfig.controls.state wiring, radioConfig.snippet
codegen, radioStyle presets, and tweenRadioStyle interpolation.
Animation model — pure snap + opt-in smooth path
Radio ships two complementary paths:
Snap path (state?: RadioState prop):
Radio is a frame-free pure renderer. The state prop drives all visuals.
Each state maps to a complete resting visual via the exported pure function
radioStyle(state, ctx) => RadioStyle. State changes snap instantly — no
tweening inside the component.
Smooth path (style?: RadioStyle prop):
Callers opt in to smooth transitions by passing a pre-interpolated RadioStyle
to the style prop. The caller — typically useRadioTransition — reads
useCurrentFrame() and calls useStateTransition from core/timeline.ts to
compute { from, to, progress }, then blends the two presets via
tweenRadioStyle(from, to, t). The Radio component itself remains
frame-free; it simply renders whatever RadioStyle it receives.
This design keeps Radio pure-testable (no Remotion render context needed)
while still supporting smooth check/uncheck transitions for production use.
How to run
The repo uses Bun, which has a built-in test runner — runs TypeScript natively, no test-framework dep.
bun install
bun test registry/remocn-ui/radio/__tests__
radio.test.ts imports bun:test (not vitest/jest), so no test script
or framework dep is added to package.json.
What is covered
RadioStateunion — asserts the two states["unchecked","checked"]are the complete set (via the realcontrols.state.optionslist fromconfig.ts).radioConfig.controls.state— the customizer control wiring. Asserts aselectcontrol exists with exactly those two options, default"checked"(so the preview shows the filled dot), and that every option is a member of theRadioStateunion.radioConfig.snippet— REAL pure string builder (high value). Asserts: emitsstate="<state>"as a bare JSX prop for every option; NEVER emitsstepsoraction; includesimport { Radio }from@/components/remocn/radio; omits default-equal props (label="",size=default,mode=light,primary=#171717); EMITS non-defaultlabel/size/mode/primary; structural round-trip (starts with import, contains<Radio, ends/>).radioStylepresets — exported pure(state, ctx) => RadioStylemap. ARadioStyleContextis built fromradioStyleContext(defaultLightTheme)— the same call the component makes internally. Asserts per-state numeric invariants (dotOpacity, dotScale) and thatringBorderColoris always a non-empty string. Also asserts the key invariant: unchecked has dotOpacity 0; checked has dotOpacity 1.tweenRadioStyle— exported pure(a, b, t) => RadioStyle. Asserts: at t=0 all numeric fields equala; at t=1 all equalb; at t=0.5 each numeric field is the exact midpoint (dotOpacity 0→1 gives 0.5, dotScale 0.4→1 gives 0.7).ringBorderColorat all t is a non-empty string (the oklch mix value is not hardcoded).
Radio render is a pure (style | state) => visual observable only via
Remotion render, not unit-tested here.
useRadioTransition reads useCurrentFrame() via useStateTransition
inside the hook — that is correct and expected. It is not a render component;
the smooth-path design isolates all frame-reading to the hook, keeping
Radio pure.
Import strategy
radio.test.ts imports via relative paths and the
@/lib/remocn-ui tsconfig alias:
../index— relative, forRadioState,radioStyle,radioStyleContext../use-radio-transition— relative, fortweenRadioStyle../config— relative, forradioConfig@/lib/remocn-ui— alias (resolves toregistry/remocn-ui/core/index.ts), fordefaultLightTheme
Importing index.tsx and use-radio-transition.ts pulls the remotion
module (and React), but neither radioStyle, radioStyleContext, nor
tweenRadioStyle call useCurrentFrame() at import time or at call time —
they are pure value functions. bun test resolves tsconfig paths, so the
alias works without additional config.
Determinism grep checklist (run manually; must print NOTHING)
Radio is frame-free. The component must contain none of the following:
grep -nE "useCurrentFrame|useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \
registry/remocn-ui/radio/index.tsx
Expected: no output. Any match is a determinism violation.
use-radio-transition.ts is the CALLER hook that intentionally reads
useCurrentFrame() (via useStateTransition). It is not a render component;
the smooth-path design isolates all frame-reading to the hook, keeping
Radio pure.
Tier-wide sweep:
grep -nE "useState|useEffect|onClick|onChange|addEventListener|Date\.now|Math\.random" \
registry/remocn-ui/radio/index.tsx registry/remocn-ui/core/*.ts