// The pure halves of the batch: the window patch an Apply writes // (tightPropose.mjs applyPatchOf) and a row as `umtool tighten` prints it. // // Run with: node --test lib/report/tightCli.test.mjs import assert from "node:assert/strict"; import test from "node:test"; import { tightLine } from "./tightCli.mjs"; import { applyPatchOf } from "./tightPropose.mjs"; const row = (o = {}) => ({ id: "t01", quote: "and because of that", section: 0, before: { start: 1.2, end: 7.4, seconds: 6.2 }, after: { start: 3.0, end: 9.0, seconds: 6 }, changed: true, how: "the sentences the cut (its quote) touches", said: ["start 3.00 → 3.01, into the pause before “And”"], why: null, fetched: true, locked: false, words: "words.json", clear: { cut: false, mute: false }, prior: { cutStart: null, cutEnd: null, muteFrom: null, cite: null, citeUrl: null }, ...o, }); test("applyPatchOf: the edges, and the cut / mute mark cleared only when they no longer fit", () => { assert.deepEqual(applyPatchOf(row()), { start: 3, end: 9 }); assert.deepEqual(applyPatchOf(row({ clear: { cut: true, mute: true } })), { start: 3, end: 9, cutStart: "", cutEnd: "", muteFrom: "" }); assert.equal(applyPatchOf(row({ after: null })), null); }); test("tightLine: before → after with the seconds, the marks, and why", () => { const l = tightLine(row({ locked: true, fetched: false })); assert.match(l, /^t01 +0:01\.20–0:07\.40 \(6\.20 s\) → 0:03\.00–0:09\.00 \(6\.00 s\) {2}−0\.20 s {2}\[locked, not fetched\]/); assert.match(l, /into the pause before/); assert.match(tightLine(row({ after: null, changed: false, why: "no cues" })), /— no cues$/); assert.match(tightLine(row({ changed: false, after: { start: 1.2, end: 7.4, seconds: 6.2 } })), /already tight/); });