Download packages/app/src/context/prompt-state.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/context/prompt-state.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/app/src/context/prompt-state.test.ts
-
curl -L -o prompt-state.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/context/prompt-state.test.ts
1.05 kB
| import { describe, expect, test } from "bun:test" | |
| import { createRoot } from "solid-js" | |
| import { createPromptState, DEFAULT_PROMPT } from "./prompt-state" | |
| describe("prompt state initialization", () => { | |
| test("initializes prompt text, cursor, and model together", () => { | |
| createRoot((dispose) => { | |
| const model = { providerID: "anthropic", modelID: "claude", variant: "high" } | |
| const prompt = createPromptState({ prompt: "hello", model }) | |
| expect(prompt.current()).toEqual([{ type: "text", content: "hello", start: 0, end: 5 }]) | |
| expect(prompt.cursor()).toBe(5) | |
| expect(prompt.model.current()).toEqual(model) | |
| expect(prompt.model.current()).not.toBe(model) | |
| dispose() | |
| }) | |
| }) | |
| test("uses the default prompt without initial values", () => { | |
| createRoot((dispose) => { | |
| const prompt = createPromptState() | |
| expect(prompt.current()).toEqual(DEFAULT_PROMPT) | |
| expect(prompt.cursor()).toBeUndefined() | |
| expect(prompt.model.current()).toBeUndefined() | |
| dispose() | |
| }) | |
| }) | |
| }) | |