import { suite } from 'uvu'; import * as assert from 'uvu/assert'; import fs from 'fs'; import path from 'path'; import { execSync } from 'child_process'; import del from 'del'; import { fileURLToPath } from 'url'; const RSS = suite('RSS Generation'); const snapshot = `<![CDATA[MF Doomcast]]>https://mysite.dev/feed/episodes.xmlen-usMF Doom<![CDATA[Rap Snitch Knishes (feat. Mr. Fantastik)]]>https://mysite.dev/episode/rap-snitch-knishes/Tue, 16 Nov 2004 05:00:00 GMTmusic172true<![CDATA[Fazers]]>https://mysite.dev/episode/fazers/Thu, 03 Jul 2003 04:00:00 GMTmusic197true<![CDATA[Rhymes Like Dimes (feat. Cucumber Slice)]]>https://mysite.dev/episode/rhymes-like-dimes/Tue, 19 Oct 1999 04:00:00 GMTmusic259true`; const cwd = new URL('./fixtures/astro-rss', import.meta.url); const clear = () => del(path.join(fileURLToPath(cwd), 'dist')); // clear dist output RSS.before(() => clear()); RSS.after(() => clear()); RSS('Generates RSS correctly', async () => { execSync('node ../../../astro.mjs build', { cwd: fileURLToPath(cwd) }); const rss = await fs.promises.readFile(path.join(fileURLToPath(cwd), 'dist', 'feed', 'episodes.xml'), 'utf8'); assert.match(rss, snapshot); }); RSS.run();