import { test } from "node:test"; import assert from "node:assert/strict"; import { TURN_ON_CONFIRMATION, cleanConfirmationText } from "./cleanAudioConfirm"; // Run with: // pnpm --filter yt-dlp-transcript-common exec tsx --test lib/cleanAudioConfirm.test.ts // // THE ONE COUNTED CONFIRMATION every button that would clean without checking // shows (lane clean-unverified, ruling 6), word for word. test("the counted confirmation states what goes, that the source is not asked, and what is kept", () => { const t = cleanConfirmationText({ files: 40, bytes: 3 * 1024 ** 3, videos: 38, protected: 12, awaitingDiarization: 3, awaitingVoiceprint: 1 }); assert.match( t.ask, /^Remove 40 audio files \(.+\) from 38 transcribed videos without checking\? The source is not asked, so the audio of videos no longer available anywhere is removed too\.$/, ); assert.equal( t.kept, "Kept: 12 marked do not clean or in the keep-latest window, 3 awaiting diarization, 1 awaiting voice fingerprint. Videos with no transcript are not touched, and no saved video is.", ); assert.equal(t.button, "Remove 40 files without checking"); const one = cleanConfirmationText({ files: 1, bytes: 10, videos: 1, protected: 0, awaitingDiarization: 0, awaitingVoiceprint: 0 }); assert.match(one.ask, /^Remove 1 audio file \(.+\) from 1 transcribed video without checking\?/); assert.equal(one.button, "Remove 1 file without checking"); const none = cleanConfirmationText({ files: 0, bytes: 0, videos: 0, protected: 2, awaitingDiarization: 0, awaitingVoiceprint: 0 }); assert.match(none.ask, /^Nothing to remove/); }); test("turning the channel key on states what it changes before it changes it", () => { assert.match(TURN_ON_CONFIRMATION, /^Turn on cleaning without checking for this channel\?/); assert.match(TURN_ON_CONFIRMATION, /without asking the source whether the video is still there/); assert.match(TURN_ON_CONFIRMATION, /these do not: clean after capture/); assert.match(TURN_ON_CONFIRMATION, /a Retry \(or Retry all failed\) of an earlier clean, and a clean a restart re-queues/); });