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

import { describe, expect, it } from "vitest";
import { byPublished, published, topSegment } from "./notes";

describe("published", () => {
  it("filters drafts", () => {
    expect(published({ data: { draft: true } })).toBe(false);
    expect(published({ data: { draft: false } })).toBe(true);
    expect(published({ data: {} })).toBe(true);
  });
});

describe("topSegment", () => {
  it("takes the first directory of an id", () => {
    expect(topSegment("nix/flakes")).toBe("nix");
    expect(topSegment("ooknet-org/design/frames")).toBe("ooknet-org");
    expect(topSegment("orphan")).toBe("orphan");
  });
});

describe("byPublished", () => {
  it("sorts by date then id", () => {
    const entries = [
      { id: "b", data: { published: "2026-04-27" } },
      { id: "a", data: { published: "2026-04-19" } },
      { id: "c", data: { published: "2026-04-19" } },
    ];
    expect(entries.sort(byPublished).map((e) => e.id)).toEqual(["a", "c", "b"]);
  });
});

import { describe, expect, it } from "vitest
";
import { byPublished, published, topSegment 
} from "./notes";

describe("published", () => {
  it("filters drafts", () => {
    expect(published({ data: { draft: true }
 })).toBe(false);
    expect(published({ data: { draft: false 
} })).toBe(true);
    expect(published({ data: {} })).toBe(tru
e);
  });
});

describe("topSegment", () => {
  it("takes the first directory of an id", (
) => {
    expect(topSegment("nix/flakes")).toBe("n
ix");
    expect(topSegment("ooknet-org/design/fra
mes")).toBe("ooknet-org");
    expect(topSegment("orphan")).toBe("orpha
n");
  });
});

describe("byPublished", () => {
  it("sorts by date then id", () => {
    const entries = [
      { id: "b", data: { published: "2026-04
-27" } },
      { id: "a", data: { published: "2026-04
-19" } },
      { id: "c", data: { published: "2026-04
-19" } },
    ];
    expect(entries.sort(byPublished).map((e)
 => e.id)).toEqual(["a", "c", "b"]);
  });
});
 
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET