Initial 智念AIGC platform
This commit is contained in:
37
tests/video-settings.test.ts
Normal file
37
tests/video-settings.test.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
VIDEO_DURATION_AUTO,
|
||||
VIDEO_DURATION_DEFAULT,
|
||||
VIDEO_DURATION_MAX,
|
||||
VIDEO_DURATION_MIN,
|
||||
clampVideoDuration,
|
||||
normalizeVideoDuration,
|
||||
normalizeVideoRatio,
|
||||
normalizeVideoResolution
|
||||
} from "@/lib/video-settings";
|
||||
|
||||
describe("video settings", () => {
|
||||
it("clamps duration to the supported range", () => {
|
||||
expect(clampVideoDuration(2)).toBe(VIDEO_DURATION_MIN);
|
||||
expect(clampVideoDuration(999)).toBe(VIDEO_DURATION_MAX);
|
||||
expect(clampVideoDuration(12.6)).toBe(13);
|
||||
});
|
||||
|
||||
it("supports Seedance auto duration only when allowed", () => {
|
||||
expect(normalizeVideoDuration(VIDEO_DURATION_AUTO)).toBe(VIDEO_DURATION_AUTO);
|
||||
expect(clampVideoDuration(VIDEO_DURATION_AUTO, VIDEO_DURATION_DEFAULT, { allowAuto: false })).toBe(VIDEO_DURATION_MIN);
|
||||
});
|
||||
|
||||
it("keeps empty duration optional and falls back for invalid values", () => {
|
||||
expect(normalizeVideoDuration(undefined)).toBeUndefined();
|
||||
expect(normalizeVideoDuration("")).toBeUndefined();
|
||||
expect(clampVideoDuration("not-a-number")).toBe(VIDEO_DURATION_DEFAULT);
|
||||
});
|
||||
|
||||
it("normalizes ratio and resolution to Seedance 2.0 supported values", () => {
|
||||
expect(normalizeVideoRatio("21:9")).toBe("21:9");
|
||||
expect(normalizeVideoRatio("bad-ratio")).toBe("9:16");
|
||||
expect(normalizeVideoResolution("1080p", "doubao-seedance-2-0-260128")).toBe("1080p");
|
||||
expect(normalizeVideoResolution("1080p", "doubao-seedance-2-0-fast-260128")).toBe("720p");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user