master @ 29 LINES
[ HISTORY ] [ UP ]
┌─ TS ───────────────────────────────────────────────────────────────────────┐
│ import { describe, expect, it } from "vitest"; │
│ import { BACKLINKS_INDENT, layoutBacklinks } from "./ArticleBacklinks"; │
│ import { len } from "../../lib/ascii"; │
│ │
│ const ref = (label: string) => ({ url: "/notes/x/", label }); │
│ │
│ describe("layoutBacklinks", () => { │
│ it("passes short labels through", () => { │
│ const rows = layoutBacklinks([ref("N0 - STYLE SHEET")], 86); │
│ expect(rows[0].label).toBe("N0 - STYLE SHEET"); │
│ }); │
│ │
│ it("truncates labels to the available width with an ellipsis", () => { │
│ const long = "N218 - COLLECT DATA TO ANALYZE AND TROUBLESHOOT PERFORMANCE SCEN │
│ ARIOS"; │
│ const rows = layoutBacklinks([ref(long)], 48); │
│ expect(len(rows[0].label)).toBe(48 - BACKLINKS_INDENT); │
│ expect(rows[0].label.endsWith("...")).toBe(true); │
│ }); │
│ │
│ it("keeps every row on the grid at both frame widths", () => { │
│ const refs = [ref("N0 - STYLE SHEET"), ref("DOCS - FRAMES")]; │
│ for (const w of [86, 48]) { │
│ for (const r of layoutBacklinks(refs, w)) { │
│ expect(len(r.label)).toBeLessThanOrEqual(w - BACKLINKS_INDENT); │
│ } │
│ } │
│ }); │
│ }); │
└────────────────────────────────────────────────────────────────────────────────────┘
┌─ TS ─────────────────────────────────┐
│ import { describe, expect, it } from "vitest │
│ "; │
│ import { BACKLINKS_INDENT, layoutBacklinks } │
│ from "./ArticleBacklinks"; │
│ import { len } from "../../lib/ascii"; │
│ │
│ const ref = (label: string) => ({ url: "/not │
│ es/x/", label }); │
│ │
│ describe("layoutBacklinks", () => { │
│ it("passes short labels through", () => { │
│ const rows = layoutBacklinks([ref("N0 - │
│ STYLE SHEET")], 86); │
│ expect(rows[0].label).toBe("N0 - STYLE S │
│ HEET"); │
│ }); │
│ │
│ it("truncates labels to the available widt │
│ h with an ellipsis", () => { │
│ const long = "N218 - COLLECT DATA TO ANA │
│ LYZE AND TROUBLESHOOT PERFORMANCE SCENARIOS" │
│ ; │
│ const rows = layoutBacklinks([ref(long)] │
│ , 48); │
│ expect(len(rows[0].label)).toBe(48 - BAC │
│ KLINKS_INDENT); │
│ expect(rows[0].label.endsWith("...")).to │
│ Be(true); │
│ }); │
│ │
│ it("keeps every row on the grid at both fr │
│ ame widths", () => { │
│ const refs = [ref("N0 - STYLE SHEET"), r │
│ ef("DOCS - FRAMES")]; │
│ for (const w of [86, 48]) { │
│ for (const r of layoutBacklinks(refs, │
│ w)) { │
│ expect(len(r.label)).toBeLessThanOrE │
│ qual(w - BACKLINKS_INDENT); │
│ } │
│ } │
│ }); │
│ }); │
└──────────────────────────────────────────────┘
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET