21 lines
1.4 KiB
TypeScript
21 lines
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { quoteFromPriceRule } from "@/lib/billing";
|
|
import { DEFAULT_BILLING_PRICE_RULES } from "@/lib/server/billing-catalog";
|
|
import type { BillingParameterSnapshot, BillingPriceRule } from "@/lib/types";
|
|
|
|
describe("EvoLink Image 2.5 prices", () => {
|
|
it.each(["gpt-image-2.5-flare", "gpt-image-2.5-sunburst"])("quotes independent quality tiers for %s", (model) => {
|
|
const rule = DEFAULT_BILLING_PRICE_RULES.find((rule) => rule.reqKey === model) as BillingPriceRule;
|
|
for (const [quality, cost, amount] of [["low", 4, 5], ["medium", 9, 11], ["high", 35, 42]] as const) {
|
|
for (const aspectRatio of ["1:1", "3:4", "70:99", "99:70"]) {
|
|
const quote = quoteFromPriceRule({ rule, provider: "evolink", capability: "image.generate", reqKey: model, quantity: 1, parameters: { quality, aspectRatio } });
|
|
expect(quote).toMatchObject({ priceRuleId: `base-evolink-${model}`, standardUnitPriceFen: cost, amountFen: amount });
|
|
}
|
|
}
|
|
const unsupported: BillingParameterSnapshot[] = [{ quality: "xhigh" }, { resolution: "2K" }, { resolution: "4K" }];
|
|
for (const parameters of unsupported) {
|
|
expect(() => quoteFromPriceRule({ rule, provider: "evolink", capability: "image.generate", reqKey: model, quantity: 1, parameters })).toThrow("当前生成参数没有对应的平台标准价格");
|
|
}
|
|
});
|
|
});
|