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

import { describe, expect, it } from "vitest";
import { buildRss, buildSitemap } from "./feeds";

const item = {
  title: "ENTROPY <BOUNDS> & GRAPHS",
  url: "https://ooknet.org/notes/n217-entropy-bounds/",
  published: "2026-04-01",
  description: 'Bounds on "sparse" graphs.',
};

describe("buildRss", () => {
  const xml = buildRss({
    title: "OOKNET KB",
    site: "https://ooknet.org/",
    description: "notes feed",
    items: [item],
  });

  it("escapes xml in titles and descriptions", () => {
    expect(xml).toContain("ENTROPY &lt;BOUNDS&gt; &amp; GRAPHS");
    expect(xml).toContain("&quot;sparse&quot;");
    expect(xml).not.toContain("<BOUNDS>");
  });

  it("formats pubDate as RFC 822", () => {
    expect(xml).toContain("<pubDate>Wed, 01 Apr 2026");
  });

  it("links item and self", () => {
    expect(xml).toContain(`<link>${item.url}</link>`);
    expect(xml).toContain('href="https://ooknet.org/rss.xml" rel="self"');
  });
});

describe("buildSitemap", () => {
  it("emits one url entry per page, lastmod only when known", () => {
    const xml = buildSitemap([
      { loc: "https://ooknet.org/" },
      { loc: "https://ooknet.org/notes/n217-entropy-bounds/", lastmod: "2026-04-01
" },
    ]);
    expect(xml.match(/<url>/g)).toHaveLength(2);
    expect(xml.match(/<lastmod>/g)).toHaveLength(1);
    expect(xml).toContain("<lastmod>2026-04-01</lastmod>");
  });
});

import { describe, expect, it } from "vitest
";
import { buildRss, buildSitemap } from "./fe
eds";

const item = {
  title: "ENTROPY <BOUNDS> & GRAPHS",
  url: "https://ooknet.org/notes/n217-entrop
y-bounds/",
  published: "2026-04-01",
  description: 'Bounds on "sparse" graphs.',
};

describe("buildRss", () => {
  const xml = buildRss({
    title: "OOKNET KB",
    site: "https://ooknet.org/",
    description: "notes feed",
    items: [item],
  });

  it("escapes xml in titles and descriptions
", () => {
    expect(xml).toContain("ENTROPY &lt;BOUND
S&gt; &amp; GRAPHS");
    expect(xml).toContain("&quot;sparse&quot
;");
    expect(xml).not.toContain("<BOUNDS>");
  });

  it("formats pubDate as RFC 822", () => {
    expect(xml).toContain("<pubDate>Wed, 01 
Apr 2026");
  });

  it("links item and self", () => {
    expect(xml).toContain(`<link>${item.url}
</link>`);
    expect(xml).toContain('href="https://ook
net.org/rss.xml" rel="self"');
  });
});

describe("buildSitemap", () => {
  it("emits one url entry per page, lastmod 
only when known", () => {
    const xml = buildSitemap([
      { loc: "https://ooknet.org/" },
      { loc: "https://ooknet.org/notes/n217-
entropy-bounds/", lastmod: "2026-04-01" },
    ]);
    expect(xml.match(/<url>/g)).toHaveLength
(2);
    expect(xml.match(/<lastmod>/g)).toHaveLe
ngth(1);
    expect(xml).toContain("<lastmod>2026-04-
01</lastmod>");
  });
});
 
──────────────────────────────────────────────────────────────────────────────────────
OOKNET
────────────────────────────────────────────────
OOKNET