import test from "node:test"; import assert from "node:assert/strict"; import { extractVideoTaskId, extractVideoUrl, normalizeAssetReference, normalizeVideoStatus, } from "../lib/normalize.mjs"; test("素材审核返回值统一为 asset 协议并保留大小写", () => { assert.equal(normalizeAssetReference({ asset_url: "Asset://asset-1" }), "asset://asset-1"); assert.equal(normalizeAssetReference({ downstream_asset_id: "asset-2" }), "asset://asset-2"); assert.equal(normalizeAssetReference({ Id: "asset-3" }), "asset://asset-3"); assert.equal(normalizeAssetReference({ asset_id: "mat_ADyx4iQv" }), "asset://mat_ADyx4iQv"); }); test("兼容视频任务 id 和状态字段", () => { assert.equal(extractVideoTaskId({ task_id: "task-1" }), "task-1"); assert.equal(extractVideoTaskId({ data: { id: "task-2" } }), "task-2"); assert.equal(normalizeVideoStatus({ status: "succeeded" }), "completed"); assert.equal(normalizeVideoStatus({ data: { status: "failed" } }), "failed"); }); test("从常见响应位置提取视频地址", () => { assert.equal(extractVideoUrl({ output: { video_url: "https://example.com/demo.mp4" } }), "https://example.com/demo.mp4"); });