|
| 1 | +import { test, expect, describe } from "bun:test" |
| 2 | +import { resolveDefaultModel } from "../../src/acp/resolve-model" |
| 3 | +import { ProviderID, ModelID } from "../../src/provider/schema" |
| 4 | + |
| 5 | +describe("resolveDefaultModel", () => { |
| 6 | + const mimo = { |
| 7 | + providerID: ProviderID.make("mimo"), |
| 8 | + modelID: ModelID.make("mimo-auto"), |
| 9 | + } |
| 10 | + |
| 11 | + test("returns specified when provider is not in providers list", () => { |
| 12 | + const result = resolveDefaultModel(mimo, [ |
| 13 | + { id: "xiaomi", models: { "some-model": {} } }, |
| 14 | + ]) |
| 15 | + expect(result).toEqual(mimo) |
| 16 | + }) |
| 17 | + |
| 18 | + test("returns specified when provider exists but model not indexed", () => { |
| 19 | + const result = resolveDefaultModel(mimo, [ |
| 20 | + { id: "mimo", models: {} }, |
| 21 | + ]) |
| 22 | + expect(result).toEqual(mimo) |
| 23 | + }) |
| 24 | + |
| 25 | + test("returns specified when providers list is empty", () => { |
| 26 | + const result = resolveDefaultModel(mimo, []) |
| 27 | + expect(result).toEqual(mimo) |
| 28 | + }) |
| 29 | + |
| 30 | + test("returns specified when provider and model both present", () => { |
| 31 | + const result = resolveDefaultModel(mimo, [ |
| 32 | + { id: "mimo", models: { "mimo-auto": { id: "mimo-auto" } } }, |
| 33 | + ]) |
| 34 | + expect(result).toEqual(mimo) |
| 35 | + }) |
| 36 | + |
| 37 | + test("returns undefined when no specified model", () => { |
| 38 | + const result = resolveDefaultModel(undefined, [ |
| 39 | + { id: "mimo", models: { "mimo-auto": {} } }, |
| 40 | + ]) |
| 41 | + expect(result).toBeUndefined() |
| 42 | + }) |
| 43 | + |
| 44 | + test("returns undefined when no specified and no providers", () => { |
| 45 | + const result = resolveDefaultModel(undefined, []) |
| 46 | + expect(result).toBeUndefined() |
| 47 | + }) |
| 48 | +}) |
0 commit comments