diff options
author | 2021-04-23 10:44:41 -0600 | |
---|---|---|
committer | 2021-04-23 10:44:41 -0600 | |
commit | 510e7920d267e8181f255d3b321bbfda11417d33 (patch) | |
tree | 8b202aa3df022116375fd2e5de46657fdf2e85cb /test/astro-rss.test.js | |
parent | 5eb232501f8f02236e52cf945b7fa3ce5a2ec260 (diff) | |
download | astro-510e7920d267e8181f255d3b321bbfda11417d33.tar.gz astro-510e7920d267e8181f255d3b321bbfda11417d33.tar.zst astro-510e7920d267e8181f255d3b321bbfda11417d33.zip |
Add RSS generation (#123)
Diffstat (limited to 'test/astro-rss.test.js')
-rw-r--r-- | test/astro-rss.test.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/astro-rss.test.js b/test/astro-rss.test.js new file mode 100644 index 000000000..53a48f158 --- /dev/null +++ b/test/astro-rss.test.js @@ -0,0 +1,27 @@ +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 = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[MF Doomcast]]></title><description><![CDATA[The podcast about the things you find on a picnic, or at a picnic table]]></description><link>https://mysite.dev/feed/episodes.xml</link><language>en-us</language><itunes:author>MF Doom</itunes:author><item><title><![CDATA[Rap Snitch Knishes (feat. Mr. Fantastik)]]></title><link>https://mysite.dev/episode/rap-snitch-knishes/</link><description><![CDATA[Complex named this song the “22nd funniest rap song of all time.”]]></description><pubDate>Tue, 16 Nov 2004 07:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>172</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Fazers]]></title><link>https://mysite.dev/episode/fazers/</link><description><![CDATA[Rhapsody ranked Take Me to Your Leader 17th on its list “Hip-Hop’s Best Albums of the Decade”]]></description><pubDate>Thu, 03 Jul 2003 06:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>197</itunes:duration><itunes:explicit>true</itunes:explicit></item><item><title><![CDATA[Rhymes Like Dimes (feat. Cucumber Slice)]]></title><link>https://mysite.dev/episode/rhymes-like-dimes/</link><description><![CDATA[Operation: Doomsday has been heralded as an underground classic that established MF Doom's rank within the underground hip-hop scene during the early to mid-2000s. +]]></description><pubDate>Tue, 19 Oct 1999 06:00:00 GMT</pubDate><itunes:episodeType>music</itunes:episodeType><itunes:duration>259</itunes:duration><itunes:explicit>true</itunes:explicit></item></channel></rss>`; + +const cwd = new URL('./fixtures/astro-rss', import.meta.url); + +const clear = () => del(path.join(fileURLToPath(cwd), '_site')); // clear _site 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), '_site', 'feed', 'episodes.xml'), 'utf8'); + assert.match(rss, snapshot); +}); + +RSS.run(); |