|
| 1 | +import { describe, expect, test } from "bun:test" |
| 2 | +import { ZenData } from "../src/model" |
| 3 | + |
| 4 | +const base = { |
| 5 | + zenModels: { |
| 6 | + "gpt-5.6-sol": { |
| 7 | + name: "GPT-5.6 Sol", |
| 8 | + cost: { input: 2, output: 10 }, |
| 9 | + costMultiplier: 1, |
| 10 | + providers: [{ id: "openai", model: "gpt-5.6-sol" }], |
| 11 | + }, |
| 12 | + }, |
| 13 | + liteModels: {}, |
| 14 | + providers: { openai: { api: "https://api.openai.com/v1", apiKey: "test" } }, |
| 15 | +} |
| 16 | + |
| 17 | +const entry = (data: ReturnType<typeof ZenData.validate>) => { |
| 18 | + const value = data.zenModels["gpt-5.6-sol"] |
| 19 | + return Array.isArray(value) ? value[0] : value |
| 20 | +} |
| 21 | + |
| 22 | +describe("ZenData cost200K threshold", () => { |
| 23 | + test("defaults to 200_000 when not configured", () => { |
| 24 | + const data = ZenData.validate({ |
| 25 | + ...base, |
| 26 | + zenModels: { |
| 27 | + "gpt-5.6-sol": { |
| 28 | + ...base.zenModels["gpt-5.6-sol"], |
| 29 | + // The secret arrives as parsed JSON in production, so untyped here too. |
| 30 | + cost200K: JSON.parse('{"input":4,"output":15}'), |
| 31 | + }, |
| 32 | + }, |
| 33 | + }) |
| 34 | + expect(entry(data).cost200K?.threshold).toBe(200_000) |
| 35 | + }) |
| 36 | + |
| 37 | + test("accepts an explicit 272_000 threshold", () => { |
| 38 | + const data = ZenData.validate({ |
| 39 | + ...base, |
| 40 | + zenModels: { |
| 41 | + "gpt-5.6-sol": { |
| 42 | + ...base.zenModels["gpt-5.6-sol"], |
| 43 | + cost200K: { input: 4, output: 15, threshold: 272_000 }, |
| 44 | + }, |
| 45 | + }, |
| 46 | + }) |
| 47 | + expect(entry(data).cost200K?.threshold).toBe(272_000) |
| 48 | + }) |
| 49 | +}) |
0 commit comments