fix: mock models.dev pricing in credit cost unit test

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Charlie Lamb
2026-06-10 19:59:35 +01:00
parent 199613849d
commit 325af4dda2

View File

@@ -1,17 +1,23 @@
import { describe, expect, test } from "bun:test";
import { describe, expect, mock, test } from "bun:test";
import {
ErrCode,
type Feature,
FeatureType,
FeatureUsageType,
} from "@autumn/shared";
import {
getModelCreditCost,
getModelCreditCostBreakdown,
} from "@/internal/features/aiCreditSystemUtils.js";
import { getCreditCost } from "@/internal/features/creditSystemUtils.js";
// Uses custom/* models so pricing resolves offline (no models.dev fetch).
mock.module("@/internal/features/utils/getModelPricing.js", () => ({
getModelsDevPricing: async () => ({}),
}));
const { getModelCreditCost, getModelCreditCostBreakdown } = await import(
"@/internal/features/aiCreditSystemUtils.js"
);
const { getCreditCost } = await import(
"@/internal/features/creditSystemUtils.js"
);
// custom/* models price from model_markups; pricing data is mocked empty.
const CUSTOM_MODEL = "custom/foo";
const aiCreditFeature: Feature = {