50 lines
1.9 KiB
TypeScript
50 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
calculateSeedanceActualAmountFen,
|
|
estimateSeedanceAmountFen,
|
|
normalizeInputVideoDuration,
|
|
seedanceTokenPriceFenPerMillion
|
|
} from "@/lib/server/seedance-billing";
|
|
import { SEEDANCE_20_MODEL, SEEDANCE_25_MODEL } from "@/lib/video-settings";
|
|
|
|
describe("Seedance model-aware billing", () => {
|
|
it("keeps Seedance 2.0 rates and adds the official Seedance 2.5 rates", () => {
|
|
expect(seedanceTokenPriceFenPerMillion(SEEDANCE_20_MODEL, "720p", false)).toBe(4_600);
|
|
expect(seedanceTokenPriceFenPerMillion(SEEDANCE_20_MODEL, "1080p", true)).toBe(3_100);
|
|
expect(seedanceTokenPriceFenPerMillion(SEEDANCE_25_MODEL, "720p", false)).toBe(7_000);
|
|
expect(seedanceTokenPriceFenPerMillion(SEEDANCE_25_MODEL, "720p", true)).toBe(4_200);
|
|
expect(seedanceTokenPriceFenPerMillion(SEEDANCE_25_MODEL, "1080p", false)).toBe(7_700);
|
|
expect(seedanceTokenPriceFenPerMillion(SEEDANCE_25_MODEL, "1080p", true)).toBe(4_600);
|
|
});
|
|
|
|
it("quotes Seedance 2.5 with a 1.2 markup and its 4-to-30-second input billing range", () => {
|
|
expect(estimateSeedanceAmountFen({
|
|
model: SEEDANCE_25_MODEL,
|
|
resolution: "720p",
|
|
aspectRatio: "16:9",
|
|
outputDurationSeconds: 5,
|
|
markupMultiplier: 1.2
|
|
})).toBe(908);
|
|
expect(normalizeInputVideoDuration(2, SEEDANCE_25_MODEL)).toBe(4);
|
|
expect(normalizeInputVideoDuration(undefined, SEEDANCE_25_MODEL)).toBe(30);
|
|
expect(estimateSeedanceAmountFen({
|
|
model: SEEDANCE_25_MODEL,
|
|
resolution: "720p",
|
|
aspectRatio: "16:9",
|
|
outputDurationSeconds: 5,
|
|
inputVideo: true,
|
|
inputVideoDurationSeconds: 2,
|
|
markupMultiplier: 1.2
|
|
})).toBe(980);
|
|
});
|
|
|
|
it("settles Seedance 2.5 provider tokens with the selected model rate", () => {
|
|
expect(calculateSeedanceActualAmountFen({
|
|
model: SEEDANCE_25_MODEL,
|
|
resolution: "720p",
|
|
completionTokens: 100_000,
|
|
markupMultiplier: 1.2
|
|
})).toBe(840);
|
|
});
|
|
});
|