import { costMicros, DRAFTING_MODELS, DEFAULT_DRAFTING_MODEL, isDraftingModel } from '../../src/intake/models'; // Rates confirmed against the pricing page on 2026-08-31: Sonnet 5 is $2 per // million input tokens and $10 per million output. describe('costMicros', () => { it('prices a million input tokens at two dollars', () => { expect(costMicros('claude-sonnet-5', 1_000_000, 0)).toBe(2_000_000); }); it('prices a million output tokens at ten dollars', () => { expect(costMicros('claude-sonnet-5', 0, 1_000_000)).toBe(10_000_000); }); it('adds both halves', () => { expect(costMicros('claude-sonnet-5', 1_000_000, 1_000_000)).toBe(12_000_000); }); it('rounds to whole micros rather than carrying a fraction', () => { expect(Number.isInteger(costMicros('claude-sonnet-5', 1, 1))).toBe(true); }); // An unknown model must not silently price at zero, which would make a budget // ceiling read as unspent however much was actually used. it('falls back to a non-zero rate for an unrecognised model', () => { expect(costMicros('some-future-model', 1_000_000, 0)).toBeGreaterThan(0); }); it('charges nothing for nothing', () => { expect(costMicros('claude-sonnet-5', 0, 0)).toBe(0); }); }); describe('the model catalogue', () => { it('offers the default as one of its choices', () => { expect(DRAFTING_MODELS.map((m) => m.id)).toContain(DEFAULT_DRAFTING_MODEL); }); // The settings dropdown and the price table are the same list precisely so // they cannot drift. If a model were ever priced by the fallback, the figure // shown next to it in Admin would not be the figure it is billed at. it('prices every model it offers', () => { for (const model of DRAFTING_MODELS) { expect(model.inputRate).toBeGreaterThan(0); expect(model.outputRate).toBeGreaterThan(0); } }); it('recognises exactly the models it offers', () => { expect(isDraftingModel(DEFAULT_DRAFTING_MODEL)).toBe(true); expect(isDraftingModel('claude-sonnet-5-typo')).toBe(false); expect(isDraftingModel('')).toBe(false); }); });