OOKNET                             [ /  search the index  ]  
──────────────────────────────────────────────────────────────────────────────────────
══════════════════════════════════════════════════════════════════════════════════════
OOKNET   [ /  search  ]  
────────────────────────────────────────────────
════════════════════════════════════════════════
 
 
master @ 37 LINES
 
[ HISTORY ]  [ UP ]
 

import { describe, expect, it } from "vitest";
import { CRUMB_LABEL, crumbs, layoutCrumbs } from "./Breadcrumbs";
import { len } from "../../lib/ascii";

describe("crumbs", () => {
  it("splits the filed path into linked segments", () => {
    expect(crumbs("/META/STYLE/SHEET")).toEqual([
      { label: "META", href: "/?q=meta" },
      { label: "STYLE", href: "/?q=style" },
      { label: "SHEET", href: "/?q=sheet" },
    ]);
  });

  it("ignores empty segments", () => {
    expect(crumbs("//INFO/")).toHaveLength(1);
  });
});

describe("layoutCrumbs", () => {
  const rowLen = (row: { label: string }[]) =>
    row.reduce((s, c) => s + 1 + len(c.label), 0);

  it("keeps a short path on one row", () => {
    expect(layoutCrumbs(crumbs("/META/STYLE/SHEET"), 48)).toHaveLength(1);
  });

  it("wraps at segment boundaries within the width", () => {
    const items = crumbs("/INFO/GRAPH/ENTROPY/BOUND/SPARSE/WINDOWS/PERF");
    const rows = layoutCrumbs(items, 48);
    expect(rows.length).toBeGreaterThan(1);
    for (const row of rows) {
      expect(rowLen(row)).toBeLessThanOrEqual(48 - len(CRUMB_LABEL));
    }
    expect(rows.flat()).toEqual(items);
  });
});

import { describe, expect, it } from "vitest
";
import { CRUMB_LABEL, crumbs, layoutCrumbs }
 from "./Breadcrumbs";
import { len } from "../../lib/ascii";

describe("crumbs", () => {
  it("splits the filed path into linked segm
ents", () => {
    expect(crumbs("/META/STYLE/SHEET")).toEq
ual([
      { label: "META", href: "/?q=meta" },
      { label: "STYLE", href: "/?q=style" },
      { label: "SHEET", href: "/?q=sheet" },
    ]);
  });

  it("ignores empty segments", () => {
    expect(crumbs("//INFO/")).toHaveLength(1
);
  });
});

describe("layoutCrumbs", () => {
  const rowLen = (row: { label: string }[]) 
=>
    row.reduce((s, c) => s + 1 + len(c.label
), 0);

  it("keeps a short path on one row", () => 
{
    expect(layoutCrumbs(crumbs("/META/STYLE/
SHEET"), 48)).toHaveLength(1);
  });

  it("wraps at segment boundaries within the
 width", () => {
    const items = crumbs("/INFO/GRAPH/ENTROP
Y/BOUND/SPARSE/WINDOWS/PERF");
    const rows = layoutCrumbs(items, 48);
    expect(rows.length).toBeGreaterThan(1);
    for (const row of rows) {
      expect(rowLen(row)).toBeLessThanOrEqua
l(48 - len(CRUMB_LABEL));
    }
    expect(rows.flat()).toEqual(items);
  });
});
 
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET