diff options
author | 2022-12-14 14:39:48 +0100 | |
---|---|---|
committer | 2022-12-14 08:39:48 -0500 | |
commit | c4155daeabe1b8191ad9ed1fa5893759f1fe5c4c (patch) | |
tree | 447042aca45a45099906d2cd685641d61a691914 /packages/astro-rss/test/rss.test.js | |
parent | d7da0996b6b80499a6f8f2c86a5cfc3e39f741d2 (diff) | |
download | astro-c4155daeabe1b8191ad9ed1fa5893759f1fe5c4c.tar.gz astro-c4155daeabe1b8191ad9ed1fa5893759f1fe5c4c.tar.zst astro-c4155daeabe1b8191ad9ed1fa5893759f1fe5c4c.zip |
fix missing type-attribute for xsl stylesheets (#5600)
Diffstat (limited to 'packages/astro-rss/test/rss.test.js')
-rw-r--r-- | packages/astro-rss/test/rss.test.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/packages/astro-rss/test/rss.test.js b/packages/astro-rss/test/rss.test.js index c66c11eb6..95a0bbf10 100644 --- a/packages/astro-rss/test/rss.test.js +++ b/packages/astro-rss/test/rss.test.js @@ -47,6 +47,10 @@ const validXmlResult = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" const validXmlWithContentResult = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[${title}]]></title><description><![CDATA[${description}]]></description><link>${site}/</link><item><title><![CDATA[${phpFeedItemWithContent.title}]]></title><link>${site}${phpFeedItemWithContent.link}/</link><guid>${site}${phpFeedItemWithContent.link}/</guid><description><![CDATA[${phpFeedItemWithContent.description}]]></description><pubDate>${new Date(phpFeedItemWithContent.pubDate).toUTCString()}</pubDate><content:encoded><![CDATA[${phpFeedItemWithContent.content}]]></content:encoded></item><item><title><![CDATA[${web1FeedItemWithContent.title}]]></title><link>${site}${web1FeedItemWithContent.link}/</link><guid>${site}${web1FeedItemWithContent.link}/</guid><description><![CDATA[${web1FeedItemWithContent.description}]]></description><pubDate>${new Date(web1FeedItemWithContent.pubDate).toUTCString()}</pubDate><content:encoded><![CDATA[${web1FeedItemWithContent.content}]]></content:encoded></item></channel></rss>`; // prettier-ignore const validXmlWithCustomDataResult = `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title><![CDATA[${title}]]></title><description><![CDATA[${description}]]></description><link>${site}/</link><item><title><![CDATA[${phpFeedItemWithCustomData.title}]]></title><link>${site}${phpFeedItemWithCustomData.link}/</link><guid>${site}${phpFeedItemWithCustomData.link}/</guid><description><![CDATA[${phpFeedItemWithCustomData.description}]]></description><pubDate>${new Date(phpFeedItemWithCustomData.pubDate).toUTCString()}</pubDate>${phpFeedItemWithCustomData.customData}</item><item><title><![CDATA[${web1FeedItemWithContent.title}]]></title><link>${site}${web1FeedItemWithContent.link}/</link><guid>${site}${web1FeedItemWithContent.link}/</guid><description><![CDATA[${web1FeedItemWithContent.description}]]></description><pubDate>${new Date(web1FeedItemWithContent.pubDate).toUTCString()}</pubDate><content:encoded><![CDATA[${web1FeedItemWithContent.content}]]></content:encoded></item></channel></rss>`; +// prettier-ignore +const validXmlWithStylesheet = `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/feedstylesheet.css"?><rss version="2.0"><channel><title><![CDATA[${title}]]></title><description><![CDATA[${description}]]></description><link>${site}/</link></channel></rss>`; +// prettier-ignore +const validXmlWithXSLStylesheet = `<?xml version="1.0" encoding="UTF-8"?><?xml-stylesheet href="/feedstylesheet.xsl" type="text/xsl"?><rss version="2.0"><channel><title><![CDATA[${title}]]></title><description><![CDATA[${description}]]></description><link>${site}/</link></channel></rss>`; describe('rss', () => { it('should generate on valid RSSFeedItem array', async () => { @@ -85,6 +89,30 @@ describe('rss', () => { chai.expect(body).xml.to.equal(validXmlWithCustomDataResult); }); + it('should include xml-stylesheet instruction when stylesheet is defined', async () => { + const { body } = await rss({ + title, + description, + items: [], + site, + stylesheet: '/feedstylesheet.css', + }); + + chai.expect(body).xml.to.equal(validXmlWithStylesheet); + }); + + it('should include xml-stylesheet instruction with xsl type when stylesheet is set to xsl file', async () => { + const { body } = await rss({ + title, + description, + items: [], + site, + stylesheet: '/feedstylesheet.xsl', + }); + + chai.expect(body).xml.to.equal(validXmlWithXSLStylesheet); + }); + describe('glob result', () => { it('should generate on valid result', async () => { const globResult = { |