Download packages/tui/test/context/local.test.ts from SaylorTwift/opencode: direct link, hf CLI and curl.
- Browser
- Download file 690 Bytes
-
https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/tui/test/context/local.test.ts
- Command line
-
hf download hf://SaylorTwift/opencode/packages/tui/test/context/local.test.ts
-
curl -L -o local.test.ts https://huggingface.co/SaylorTwift/opencode/resolve/main/packages/tui/test/context/local.test.ts
690 Bytes
| import { expect, test } from "bun:test" | |
| import { parseModel, recentModels } from "../../src/context/local" | |
| test("parses model IDs containing slashes", () => { | |
| expect(parseModel("provider/family/model")).toEqual({ | |
| providerID: "provider", | |
| modelID: "family/model", | |
| }) | |
| }) | |
| test("moves a model to the front, deduplicates, and limits recents", () => { | |
| const recent = Array.from({ length: 12 }, (_, index) => ({ | |
| providerID: "provider", | |
| modelID: `model-${index}`, | |
| })) | |
| expect(recentModels({ providerID: "provider", modelID: "model-5" }, recent)).toEqual([ | |
| { providerID: "provider", modelID: "model-5" }, | |
| ...recent.slice(0, 5), | |
| ...recent.slice(6, 10), | |
| ]) | |
| }) | |