38 lines
1.4 KiB
TypeScript
38 lines
1.4 KiB
TypeScript
import { readFileSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { describe, expect, it } from "@suaveplan/testing/runner";
|
|
import { VIDEO_THUMBNAILS_CODES } from "./error-codes.js";
|
|
|
|
describe("VIDEO_THUMBNAILS_CODES", () => {
|
|
it("exposes all nine codes under the VIDEO_THUMBNAILS namespace", {
|
|
timeout: 5000,
|
|
}, () => {
|
|
const values = Object.values(VIDEO_THUMBNAILS_CODES);
|
|
expect(values).toHaveLength(9);
|
|
for (const value of values) {
|
|
expect(value.startsWith("VIDEO_THUMBNAILS.")).toBe(true);
|
|
}
|
|
});
|
|
|
|
it("every code is thrown by a real call site", { timeout: 5000 }, () => {
|
|
const srcRoot = join(__dirname, "..");
|
|
const files = [
|
|
"runner/runner.ts",
|
|
"runner/fluent-ffmpeg-runner.ts",
|
|
"thumbnail-generator/thumbnail-generator.ts",
|
|
"sprite-sheet/sprite-sheet.ts",
|
|
];
|
|
const corpus = files
|
|
.map((relative) => readFileSync(join(srcRoot, relative), "utf8"))
|
|
.join("\n");
|
|
for (const [reason, code] of Object.entries(VIDEO_THUMBNAILS_CODES)) {
|
|
const accessor = `VIDEO_THUMBNAILS_CODES.${reason}`;
|
|
const hasUsage = corpus.includes(accessor);
|
|
expect(
|
|
hasUsage,
|
|
`expected ${code} (${accessor}) referenced in a src/ call site`
|
|
).toBe(true);
|
|
}
|
|
});
|
|
});
|