Download packages/app/src/components/settings-v2/general-controllers.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 1.8 kB
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/components/settings-v2/general-controllers.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/app/src/components/settings-v2/general-controllers.test.ts
-
curl -L -o general-controllers.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/app/src/components/settings-v2/general-controllers.test.ts
1.8 kB
| import { describe, expect, test, vi } from "bun:test" | |
| import { createRoot } from "solid-js" | |
| import { createShellOptions, createSoundPreviewController } from "./general-controller-behavior" | |
| describe("settings v2 controllers", () => { | |
| test("normalizes shell names and preserves an unavailable configured shell", () => { | |
| expect( | |
| createShellOptions({ | |
| shells: [ | |
| { path: "/bin/bash", name: "bash", acceptable: true }, | |
| { path: "/opt/bash", name: "bash", acceptable: false }, | |
| { path: "/bin/zsh", name: "zsh", acceptable: true }, | |
| ], | |
| current: "fish", | |
| }), | |
| ).toEqual([ | |
| { id: "auto", value: "", name: "", terminalOnly: false }, | |
| { id: "/bin/bash", value: "/bin/bash", name: "/bin/bash", terminalOnly: false }, | |
| { id: "/opt/bash", value: "/opt/bash", name: "/opt/bash", terminalOnly: true }, | |
| { id: "/bin/zsh", value: "zsh", name: "zsh", terminalOnly: false }, | |
| { id: "fish", value: "fish", name: "fish", terminalOnly: false }, | |
| ]) | |
| }) | |
| test("debounces previews and stops owned audio on disposal", async () => { | |
| vi.useFakeTimers() | |
| try { | |
| const played: string[] = [] | |
| const stopped: string[] = [] | |
| const owned = createRoot((dispose) => ({ | |
| dispose, | |
| preview: createSoundPreviewController(async (id) => { | |
| played.push(id ?? "") | |
| return () => stopped.push(id ?? "") | |
| }), | |
| })) | |
| owned.preview.play("first") | |
| vi.advanceTimersByTime(99) | |
| expect(played).toEqual([]) | |
| owned.preview.play("second") | |
| vi.advanceTimersByTime(100) | |
| await Promise.resolve() | |
| expect(played).toEqual(["second"]) | |
| owned.dispose() | |
| expect(stopped).toEqual(["second"]) | |
| } finally { | |
| vi.useRealTimers() | |
| } | |
| }) | |
| }) | |