testRssFeeds
tcmts.content.test.testRssFeeds · #mbrkplmj · function
import { rss } from "#codebase/tcmts/content";
import assert from "node:assert/strict";
export const testRssFeeds = () => {
const feed = rss({
title: "Blog",
link: "https://example.com/blog/",
self: "https://example.com/blog/rss.xml",
description: "News & notes",
items: [
{
title: "Two <b>",
link: "https://example.com/blog/two.html",
date: "2026-12-01",
author: "Ada",
html: '<p><a href="/docs/">docs</a> <a href="one.html">one</a> <a href="#x">here</a> <a href="https://x.org">x</a></p>',
},
{ title: "One", link: "https://example.com/blog/one.html", date: "2026-11-07" },
],
});
assert.equal(feed.match(/<item>/g)?.length, 2);
assert.match(feed, /<lastBuildDate>Tue, 01 Dec 2026 00:00:00 GMT<\/lastBuildDate>/);
assert.match(feed, /<pubDate>Sat, 07 Nov 2026 00:00:00 GMT<\/pubDate>/);
assert.match(feed, /<title>Two <b><\/title>/);
assert.match(feed, /<description>News & notes<\/description>/);
assert.match(feed, /<dc:creator>Ada<\/dc:creator>/);
// links made absolute, from the site's address; anchors and full ones as they are
assert.match(feed, /href="https:\/\/example\.com\/docs\/"/);
assert.match(feed, /href="https:\/\/example\.com\/blog\/one\.html"/);
assert.match(feed, /href="#x"/);
assert.match(feed, /href="https:\/\/x\.org"/);
assert.match(feed, /<atom:link href="https:\/\/example\.com\/blog\/rss\.xml" rel="self"/);
}
uses