Skip to content

Commit

Permalink
feat: 🎸 add mandatory rss2 attributes on enclosure (#120)
Browse files Browse the repository at this point in the history
Co-authored-by: Decebal Dobrica <decebal.dobrica@tellimer.com>
  • Loading branch information
Decebal Dobrica and decebal authored May 25, 2020
1 parent abfe55b commit 1693311
Show file tree
Hide file tree
Showing 7 changed files with 513 additions and 11 deletions.
1 change: 1 addition & 0 deletions src/__tests__/__snapshots__/atom1.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ exports[`atom 1.0 should generate a valid feed 1`] = `
</author>
<link rel=\\"alternate\\" href=\\"http://example.com/\\"/>
<link rel=\\"self\\" href=\\"http://example.com/sampleFeed.rss\\"/>
<link rel=\\"hub\\" href=\\"wss://example.com/\\"/>
<subtitle>This is my personnal feed!</subtitle>
<logo>http://example.com/image.png</logo>
<rights>All rights reserved 2013, John Doe</rights>
Expand Down
232 changes: 229 additions & 3 deletions src/__tests__/__snapshots__/rss2.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

exports[`rss 2.0 should generate a valid feed 1`] = `
"<?xml version=\\"1.0\\" encoding=\\"utf-8\\"?>
<rss version=\\"2.0\\" xmlns:content=\\"http://purl.org/rss/1.0/modules/content/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
<rss version=\\"2.0\\" xmlns:dc=\\"http://purl.org/dc/elements/1.1/\\" xmlns:content=\\"http://purl.org/rss/1.0/modules/content/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
<channel>
<title>Feed Title</title>
<link>http://example.com/</link>
Expand All @@ -11,14 +11,15 @@ exports[`rss 2.0 should generate a valid feed 1`] = `
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>en</language>
<ttl>60</ttl>
<image>
<title>Feed Title</title>
<url>http://example.com/image.png</url>
<link>http://example.com/</link>
</image>
<copyright>All rights reserved 2013, John Doe</copyright>
<category>Technology</category>
<atom:link href=\\"http://example.com/sampleFeed.rss\\" rel=\\"self\\" type=\\"application/rss+xml\\"/>
<atom:link href=\\"wss://example.com/\\" rel=\\"hub\\"/>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world</link>
Expand All @@ -30,7 +31,232 @@ exports[`rss 2.0 should generate a valid feed 1`] = `
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure url=\\"https://example.com/hello-world.jpg\\"/>
<enclosure url=\\"https://example.com/hello-world.jpg\\" length=\\"0\\" type=\\"image/jpg\\"/>
</item>
</channel>
</rss>"
`;
exports[`rss 2.0 should generate a valid feed with audio 1`] = `
"<?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/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
<channel>
<title>Feed Title</title>
<link>http://example.com/</link>
<description>This is my personnal feed!</description>
<lastBuildDate>Sat, 13 Jul 2013 23:00:00 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>en</language>
<ttl>60</ttl>
<image>
<title>Feed Title</title>
<url>http://example.com/image.png</url>
<link>http://example.com/</link>
</image>
<copyright>All rights reserved 2013, John Doe</copyright>
<category>Technology</category>
<atom:link href=\\"wss://example.com/\\" rel=\\"hub\\"/>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world</link>
<guid>419c523a-28f4-489c-877e-9604be64c002</guid>
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<content:encoded><![CDATA[Content of my item]]></content:encoded>
<author>janedoe@example.com (Jane Doe)</author>
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure url=\\"https://example.com/hello-world.jpg\\" length=\\"0\\" type=\\"image/jpg\\"/>
</item>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world2</link>
<guid>419c523a-28f4-489c-877e-9604be64c001</guid>
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<content:encoded><![CDATA[Content of my item]]></content:encoded>
<author>janedoe@example.com (Jane Doe)</author>
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure length=\\"12665\\" type=\\"image/jpg\\" url=\\"https://example.com/hello-world.jpg\\"/>
</item>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world2</link>
<guid>419c523a-28f4-489c-877e-9604be64c001</guid>
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<content:encoded><![CDATA[Content of my item]]></content:encoded>
<author>janedoe@example.com (Jane Doe)</author>
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure length=\\"12665\\" type=\\"image/jpg\\" url=\\"https://example.com/hello-world.jpg\\"/>
</item>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world3</link>
<guid>https://example.com/hello-world3</guid>
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<content:encoded><![CDATA[Content of my item]]></content:encoded>
<author>janedoe@example.com (Jane Doe)</author>
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure length=\\"12665\\" type=\\"audio/mpeg\\" url=\\"https://example.com/hello-world.mp3\\"/>
</item>
</channel>
</rss>"
`;
exports[`rss 2.0 should generate a valid feed with enclosure 1`] = `
"<?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/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
<channel>
<title>Feed Title</title>
<link>http://example.com/</link>
<description>This is my personnal feed!</description>
<lastBuildDate>Sat, 13 Jul 2013 23:00:00 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>en</language>
<ttl>60</ttl>
<image>
<title>Feed Title</title>
<url>http://example.com/image.png</url>
<link>http://example.com/</link>
</image>
<copyright>All rights reserved 2013, John Doe</copyright>
<category>Technology</category>
<atom:link href=\\"wss://example.com/\\" rel=\\"hub\\"/>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world</link>
<guid>419c523a-28f4-489c-877e-9604be64c002</guid>
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<content:encoded><![CDATA[Content of my item]]></content:encoded>
<author>janedoe@example.com (Jane Doe)</author>
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure url=\\"https://example.com/hello-world.jpg\\" length=\\"0\\" type=\\"image/jpg\\"/>
</item>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world2</link>
<guid>419c523a-28f4-489c-877e-9604be64c001</guid>
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<content:encoded><![CDATA[Content of my item]]></content:encoded>
<author>janedoe@example.com (Jane Doe)</author>
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure length=\\"12665\\" type=\\"image/jpg\\" url=\\"https://example.com/hello-world.jpg\\"/>
</item>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world2</link>
<guid>419c523a-28f4-489c-877e-9604be64c001</guid>
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<content:encoded><![CDATA[Content of my item]]></content:encoded>
<author>janedoe@example.com (Jane Doe)</author>
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure length=\\"12665\\" type=\\"image/jpg\\" url=\\"https://example.com/hello-world.jpg\\"/>
</item>
</channel>
</rss>"
`;
exports[`rss 2.0 should generate a valid feed with image properties 1`] = `
"<?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/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
<channel>
<title>Feed Title</title>
<link>http://example.com/</link>
<description>This is my personnal feed!</description>
<lastBuildDate>Sat, 13 Jul 2013 23:00:00 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>en</language>
<ttl>60</ttl>
<image>
<title>Feed Title</title>
<url>http://example.com/image.png</url>
<link>http://example.com/</link>
</image>
<copyright>All rights reserved 2013, John Doe</copyright>
<category>Technology</category>
<atom:link href=\\"wss://example.com/\\" rel=\\"hub\\"/>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world</link>
<guid>419c523a-28f4-489c-877e-9604be64c002</guid>
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<content:encoded><![CDATA[Content of my item]]></content:encoded>
<author>janedoe@example.com (Jane Doe)</author>
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure url=\\"https://example.com/hello-world.jpg\\" length=\\"0\\" type=\\"image/jpg\\"/>
</item>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world2</link>
<guid>419c523a-28f4-489c-877e-9604be64c001</guid>
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<content:encoded><![CDATA[Content of my item]]></content:encoded>
<author>janedoe@example.com (Jane Doe)</author>
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure length=\\"12665\\" type=\\"image/jpg\\" url=\\"https://example.com/hello-world.jpg\\"/>
</item>
</channel>
</rss>"
`;
exports[`rss 2.0 should generate a valid feed with video 1`] = `
"<?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/\\" xmlns:atom=\\"http://www.w3.org/2005/Atom\\">
<channel>
<title>Feed Title</title>
<link>http://example.com/</link>
<description>This is my personnal feed!</description>
<lastBuildDate>Sat, 13 Jul 2013 23:00:00 GMT</lastBuildDate>
<docs>https://validator.w3.org/feed/docs/rss2.html</docs>
<generator>https://github.com/jpmonette/feed</generator>
<language>en</language>
<ttl>60</ttl>
<image>
<title>Feed Title</title>
<url>http://example.com/image.png</url>
<link>http://example.com/</link>
</image>
<copyright>All rights reserved 2013, John Doe</copyright>
<atom:link href=\\"wss://example.com/\\" rel=\\"hub\\"/>
<item>
<title><![CDATA[Hello World]]></title>
<link>https://example.com/hello-world4</link>
<guid>419c523a-28f4-489c-877e-9604be64c005</guid>
<pubDate>Sat, 13 Jul 2013 23:00:00 GMT</pubDate>
<description><![CDATA[This is an article about Hello World.]]></description>
<content:encoded><![CDATA[Content of my item]]></content:encoded>
<author>janedoe@example.com (Jane Doe)</author>
<author>joesmith@example.com (Joe Smith)</author>
<category>Grateful Dead</category>
<category domain=\\"http://www.fool.com/cusips\\">MSFT</category>
<enclosure url=\\"https://example.com/hello-world.mp4\\" length=\\"0\\" type=\\"video/mp4\\"/>
</item>
</channel>
</rss>"
Expand Down
Loading

0 comments on commit 1693311

Please sign in to comment.