model.test.ts 887 B

12345678910111213141516171819202122
  1. import { describe, expect, test } from "bun:test"
  2. import { Model } from "../src/model.js"
  3. describe("Model.Ref", () => {
  4. test("parses model references with optional variants", () => {
  5. const variant = Model.Ref.parse("openrouter/openai/gpt-5#high")
  6. expect(String(variant.providerID)).toBe("openrouter")
  7. expect(String(variant.id)).toBe("openai/gpt-5")
  8. expect(String(variant.variant)).toBe("high")
  9. const standard = Model.Ref.parse("anthropic/claude-sonnet")
  10. expect(String(standard.providerID)).toBe("anthropic")
  11. expect(String(standard.id)).toBe("claude-sonnet")
  12. expect(standard.variant).toBeUndefined()
  13. })
  14. test("rejects malformed model references", () => {
  15. expect(() => Model.Ref.parse("gpt-5")).toThrow()
  16. expect(() => Model.Ref.parse("openai/gpt-5#")).toThrow()
  17. expect(() => Model.Ref.parse("openai/gpt-5#high#extra")).toThrow()
  18. })
  19. })