Download packages/app/test-browser/motion-spring.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 703 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/test-browser/motion-spring.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/app/test-browser/motion-spring.test.ts
-
curl -L -o motion-spring.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/test-browser/motion-spring.test.ts
703 Bytes
| import { expect, test } from "bun:test" | |
| import { useSpring } from "@opencode-ai/ui/motion-spring" | |
| import { createRoot, createSignal } from "solid-js" | |
| test("snaps spring progress when the session changes", async () => { | |
| const state = createRoot((dispose) => { | |
| const [target, setTarget] = createSignal(0) | |
| const [session, setSession] = createSignal("session-a") | |
| const progress = useSpring(target, { visualDuration: 0.3, bounce: 0 }, session) | |
| return { dispose, progress, setTarget, setSession } | |
| }) | |
| await new Promise<void>(queueMicrotask) | |
| state.setTarget(1) | |
| expect(state.progress()).toBe(0) | |
| state.setSession("session-b") | |
| expect(state.progress()).toBe(1) | |
| state.dispose() | |
| }) | |