The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 03:37 UTC
| 1 | import { ProviderDriverKind, ProviderInstanceId } from "@t3tools/contracts"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | |
| 4 | import { nextTextGeneratorId, textGeneratorBrand } from "./textGenerators"; |
| 5 | |
| 6 | describe("nextTextGeneratorId", () => { |
| 7 | it("skips ids that would make a selection name another target", () => { |
| 8 | const settings = { |
| 9 | providerInstances: { |
| 10 | [ProviderInstanceId.make("openai")]: { driver: ProviderDriverKind.make("codex") }, |
| 11 | }, |
| 12 | textGenerators: { |
| 13 | [ProviderInstanceId.make("openai-2")]: { |
| 14 | kind: "openaiCompatible" as const, |
| 15 | baseUrl: "https://api.openai.com/v1", |
| 16 | apiKey: "", |
| 17 | enabled: true, |
| 18 | }, |
| 19 | }, |
| 20 | }; |
| 21 | const providers = [{ instanceId: ProviderInstanceId.make("openai-3") }]; |
| 22 | |
| 23 | expect(nextTextGeneratorId("openai", settings, providers)).toBe("openai-4"); |
| 24 | // A driver's default instance id is taken even before it has a snapshot or config. |
| 25 | expect(nextTextGeneratorId("cursor", settings, [])).toBe("cursor-2"); |
| 26 | expect(nextTextGeneratorId("openrouter", settings, providers)).toBe("openrouter"); |
| 27 | }); |
| 28 | }); |
| 29 | |
| 30 | describe("textGeneratorBrand", () => { |
| 31 | it.each([ |
| 32 | ["anthropic", "https://proxy.example/v1", "anthropic"], |
| 33 | ["openaiCompatible", "https://openrouter.ai/api/v1", "openrouter"], |
| 34 | ["openaiCompatible", "https://api.openai.com/v1", "openai"], |
| 35 | ["openaiCompatible", "http://localhost:11434/v1", "ollama"], |
| 36 | ["openaiCompatible", "http://localhost:1234/v1", "openaiCompatible"], |
| 37 | ] as const)("%s at %s shows the %s icon", (kind, baseUrl, brand) => { |
| 38 | expect(textGeneratorBrand({ kind, baseUrl })).toBe(brand); |
| 39 | }); |
| 40 | }); |