| 1 | import { ProviderInstanceId } from "@t3tools/contracts"; |
| 2 | import { describe, expect, it } from "vite-plus/test"; |
| 3 | import { |
| 4 | modelPickerLegacySectionKey, |
| 5 | modelPickerModelKey, |
| 6 | parseModelPickerLegacySectionKey, |
| 7 | parseModelPickerModelKey, |
| 8 | } from "./modelPickerKeys"; |
| 9 | |
| 10 | describe("model picker item keys", () => { |
| 11 | it("keeps model and legacy section keys distinct for colliding instance names", () => { |
| 12 | const modelKey = modelPickerModelKey(ProviderInstanceId.make("legacy-models"), "codex"); |
| 13 | const sectionKey = modelPickerLegacySectionKey(ProviderInstanceId.make("codex")); |
| 14 | |
| 15 | expect(modelKey).not.toBe(sectionKey); |
| 16 | expect(parseModelPickerLegacySectionKey(modelKey)).toBeNull(); |
| 17 | expect(parseModelPickerModelKey(modelKey)).toEqual({ |
| 18 | instanceId: "legacy-models", |
| 19 | slug: "codex", |
| 20 | }); |
| 21 | }); |
| 22 | |
| 23 | it("round-trips arbitrary strings without throwing", () => { |
| 24 | const instanceId = ProviderInstanceId.make("custom"); |
| 25 | const slug = "model:\udfff"; |
| 26 | |
| 27 | const key = modelPickerModelKey(instanceId, slug); |
| 28 | |
| 29 | expect(parseModelPickerModelKey(key)).toEqual({ instanceId, slug }); |
| 30 | }); |
| 31 | }); |