import { test } from "node:test"; import assert from "node:assert/strict"; import { threadLabels } from "./cite-thread.mjs"; test("the cite's label is held clear of the end labels it shares the line with", () => { // 0:03 of 0:21 (a bench's reader): 0:00 shows, and the cite starts past it. const near = threadLabels({ pct: (3 / 21) * 100, citeChars: 4, startChars: 4, endChars: 4 }); assert.equal(near.showStart, true); assert.equal(near.showEnd, true); assert.match(near.citeLeft, /^clamp\(5ch, calc\(14\.2\d+% - 2ch\), calc\(100% - 9ch\)\)$/); // At the very start the 0:00 gives way and the cite may sit at the edge. assert.equal(threadLabels({ pct: 3, citeChars: 4, startChars: 4, endChars: 7 }).showStart, false); assert.match(threadLabels({ pct: 3, citeChars: 4, startChars: 4, endChars: 7 }).citeLeft, /^clamp\(0px,/); // Near the end the length gives way. const end = threadLabels({ pct: 98, citeChars: 7, startChars: 4, endChars: 7 }); assert.equal(end.showEnd, false); assert.match(end.citeLeft, /calc\(100% - 7ch\)\)$/); });