import test from "node:test"; import assert from "node:assert/strict"; import { attachSummaryWords, playableSummaryWords } from "./mediaToolsWords"; // Run with: pnpm -C editor exec tsx --test "app/channels/*/lib/mediaToolsWords.test.ts" const attach = { dryRun: true, counts: { attach: 2, create: 1 }, attached: 0, created: [], failed: [], notHeld: ["x9"], lost: 0, unmatched: [], ambiguous: [], alreadyAttached: 1, heldWithoutMedia: [], }; test("an attach preview and run, said in plain words", () => { assert.deepEqual(attachSummaryWords(attach), [ "Would attach 2 held videos and write 1 new record.", "1 video already had a saved file (left alone; tick Replace to swap).", "1 file for videos this channel does not hold (tick Create records to add them).", ]); const run = attachSummaryWords({ ...attach, dryRun: false, attached: 1, created: [], alreadyAttached: 0, notHeld: [], failed: [{ id: "a1", error: "disk" }], stopped: "low-disk" }); assert.deepEqual(run, ["Attached 1 video.", "1 video failed: a1 (disk).", "Stopped (low-disk): run it again to continue."]); }); test("a playable preview and run, said in plain words", () => { const s = { dryRun: true, root: "/store/playable", prepared: 1, unchanged: 2, unplayable: [{ id: "v1", reason: "hevc in webm" }], noContainer: [], failed: [] }; assert.deepEqual(playableSummaryWords(s), [ "Would make 1 playable copy; 2 already up to date.", "Under /store/playable.", "1 video cannot be made playable without re-encoding: v1 (hevc in webm).", ]); assert.match(playableSummaryWords({ ...s, dryRun: false, prepared: 3, unplayable: [] })[0]!, /^Made 3 playable copies with their torrents/); });