44 行
1.4 KiB
TypeScript
44 行
1.4 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import {
|
|
buildTutorialImageFfmpegArgs,
|
|
buildTutorialImageKey,
|
|
buildTutorialImageUrl,
|
|
getTutorialImageSpec,
|
|
} from "./tutorialImages";
|
|
|
|
describe("tutorialImages", () => {
|
|
it("maps tennis categories to image specs", () => {
|
|
expect(getTutorialImageSpec("forehand")?.sourcePageUrl).toContain("Ray_Dunlop_forehand");
|
|
expect(getTutorialImageSpec("backhand")?.sourcePageUrl).toContain("Backhand_Federer");
|
|
expect(getTutorialImageSpec("serve")?.sourcePageUrl).toContain("Serena_Williams_Serves");
|
|
expect(getTutorialImageSpec("wall")?.sourcePageUrl).toContain("Tennis_wall");
|
|
expect(getTutorialImageSpec("unknown")).toBeNull();
|
|
});
|
|
|
|
it("builds stable storage keys and public URLs", () => {
|
|
expect(buildTutorialImageKey("forehand-fundamentals")).toBe("tutorials/forehand-fundamentals.webp");
|
|
expect(buildTutorialImageUrl("forehand-fundamentals")).toBe("/uploads/tutorials/forehand-fundamentals.webp");
|
|
});
|
|
|
|
it("uses a fixed compression pipeline for tutorial images", () => {
|
|
const args = buildTutorialImageFfmpegArgs("/tmp/input.jpg", "/tmp/output.webp");
|
|
|
|
expect(args).toEqual([
|
|
"-y",
|
|
"-i",
|
|
"/tmp/input.jpg",
|
|
"-vf",
|
|
"scale=1200:675:force_original_aspect_ratio=increase,crop=1200:675",
|
|
"-frames:v",
|
|
"1",
|
|
"-c:v",
|
|
"libwebp",
|
|
"-quality",
|
|
"78",
|
|
"-compression_level",
|
|
"6",
|
|
"/tmp/output.webp",
|
|
]);
|
|
});
|
|
});
|