master @ 35 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ import { describe, expect, it } from "vitest"; │
│ import { buildKeyValue } from "./KeyValue"; │
│ import { len } from "../../lib/ascii"; │
│ │
│ describe("buildKeyValue", () => { │
│ it("hard-wraps single tokens wider than the value column", () => { │
│ const out = buildKeyValue([["SUBJECT", "feat(hosts:{ooksmedia,ooksdesk,ooknode │
│ ,ookstest})"]], 48); │
│ for (const line of out.split("\n")) expect(len(line)).toBeLessThanOrEqual(48); │
│ }); │
│ │
│ it("aligns values to the widest key plus gap", () => { │
│ const out = buildKeyValue([["AUTHOR", "OOKNET"], ["PUBLISHED", "2026-07-16"]], │
│ 48); │
│ const lines = out.split("\n"); │
│ expect(lines[0]).toBe("AUTHOR OOKNET"); │
│ expect(lines[1]).toBe("PUBLISHED 2026-07-16"); │
│ }); │
│ │
│ it("wraps long values under their own column", () => { │
│ const out = buildKeyValue([["NOTE", "a value long enough that it must wrap on │
│ narrow frames"]], 32); │
│ const lines = out.split("\n"); │
│ expect(lines.length).toBeGreaterThan(1); │
│ expect(lines[1].startsWith(" ".repeat(7))).toBe(true); │
│ for (const ln of lines) expect(len(ln)).toBeLessThanOrEqual(32); │
│ }); │
│ │
│ it("respects an explicit key width", () => { │
│ const out = buildKeyValue([["A", "B"]], 48, 12); │
│ expect(out).toBe("A B"); │
│ }); │
│ │
│ it("handles empty entries", () => { │
│ expect(buildKeyValue([], 48)).toBe(""); │
│ }); │
│ }); │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ import { describe, expect, it } from "vitest │
│ "; │
│ import { buildKeyValue } from "./KeyValue"; │
│ import { len } from "../../lib/ascii"; │
│ │
│ describe("buildKeyValue", () => { │
│ it("hard-wraps single tokens wider than th │
│ e value column", () => { │
│ const out = buildKeyValue([["SUBJECT", " │
│ feat(hosts:{ooksmedia,ooksdesk,ooknode,ookst │
│ est})"]], 48); │
│ for (const line of out.split("\n")) expe │
│ ct(len(line)).toBeLessThanOrEqual(48); │
│ }); │
│ │
│ it("aligns values to the widest key plus g │
│ ap", () => { │
│ const out = buildKeyValue([["AUTHOR", "O │
│ OKNET"], ["PUBLISHED", "2026-07-16"]], 48); │
│ const lines = out.split("\n"); │
│ expect(lines[0]).toBe("AUTHOR OOKNE │
│ T"); │
│ expect(lines[1]).toBe("PUBLISHED 2026- │
│ 07-16"); │
│ }); │
│ │
│ it("wraps long values under their own colu │
│ mn", () => { │
│ const out = buildKeyValue([["NOTE", "a v │
│ alue long enough that it must wrap on narrow │
│ frames"]], 32); │
│ const lines = out.split("\n"); │
│ expect(lines.length).toBeGreaterThan(1); │
│ expect(lines[1].startsWith(" ".repeat(7) │
│ )).toBe(true); │
│ for (const ln of lines) expect(len(ln)). │
│ toBeLessThanOrEqual(32); │
│ }); │
│ │
│ it("respects an explicit key width", () => │
│ { │
│ const out = buildKeyValue([["A", "B"]], │
│ 48, 12); │
│ expect(out).toBe("A B"); │
│ }); │
│ │
│ it("handles empty entries", () => { │
│ expect(buildKeyValue([], 48)).toBe(""); │
│ }); │
│ }); │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET