import { test } from "node:test"; import assert from "node:assert/strict"; import { formatStateDay, sourceLinkLabel, sourceMissingSentence, stateSinceTitle, } from "./sourceMissing"; // Run with: // pnpm --filter yt-dlp-transcript-common exec tsx --test lib/sourceMissing.test.ts test("the sentence names the state and the day it was first seen, and nothing else", () => { assert.equal( sourceMissingSentence({ state: "members_only", stateSince: "20261119", platform: "youtube", isLivestream: true }), "This stream is no longer public on YouTube (members-only; first seen 19 Nov 2026). The transcript is kept here.", ); assert.equal( sourceMissingSentence({ state: "private", stateSince: "20260301", platform: "rumble" }), "This video is no longer public on Rumble (private; first seen 1 Mar 2026). The transcript is kept here.", ); assert.equal( sourceMissingSentence({ state: "deleted", stateSince: "20251231", platform: "youtube" }), "This video is no longer public on YouTube (removed; first seen 31 Dec 2025). The transcript is kept here.", ); // No day: the state alone. assert.equal( sourceMissingSentence({ state: "deleted", platform: "odysee" }), "This video is no longer public on Odysee (removed). The transcript is kept here.", ); }); test("states that keep their player get no sentence", () => { for (const state of ["available", "unlisted", "maybe_missing", undefined] as const) { assert.equal(sourceMissingSentence({ state, platform: "youtube" }), null, String(state)); } }); test("the marked link, the badge title, the day format", () => { assert.equal(sourceLinkLabel("youtube", "members_only"), "Open on YouTube (members-only)"); assert.equal(sourceLinkLabel("twitch", "deleted"), "Open on Twitch (removed)"); assert.equal(sourceLinkLabel(undefined, "private"), "Open on its platform (private)"); assert.equal(stateSinceTitle("Members-only on the source platform", "20261119"), "Members-only on the source platform; first seen 19 Nov 2026"); assert.equal(stateSinceTitle("Deleted", undefined), "Deleted"); assert.equal(formatStateDay("2026-11-19"), null); assert.equal(formatStateDay("20261319"), null); });