diff --git a/test/rss.test.js b/test/rss.test.js index d035797..e9636aa 100644 --- a/test/rss.test.js +++ b/test/rss.test.js @@ -262,5 +262,113 @@ describe('rss module', function(done) { expect(result).to.equal(expectedResult); done(); }); -}); + it('should work with custom elements', function(done) { + var feed = new RSS({ + title: 'title', + description: 'description', + feed_url: 'http://example.com/rss.xml', + site_url: 'http://example.com', + author: 'Dylan Greene', + categories: ['Category 1','Category 2','Category 3'], + pubDate: 'May 20, 2012 04:00:00 GMT', + docs: 'http://example.com/rss/docs.html', + copyright: '2013 Dylan Green', + language: 'en', + managingEditor: 'Dylan Green', + webMaster: 'Dylan Green', + ttl: '60' + custom: { + 'itunes:subtitle': 'A show about everything', + 'itunes:author': 'John Doe', + 'itunes:summary': 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store', + 'itunes:owner': { + 'itunes:name': 'John Doe', + 'itunes:email': 'john.doe@example.com' + }, + 'itunes:image': { + _attr: { + href: 'http://example.com/podcasts/everything/AllAboutEverything.jpg' + } + }, + 'itunes:category': { + _attr: { + text: 'Technology' + } + 'itunes:category': { + _attr: { + text: 'Gadgets' + } + } + } + } + }); + + feed.item({ + title: 'item 1', + description: 'description 1', + url: 'http://example.com/article1', + date: 'May 24, 2012 04:00:00 GMT', + custom: { + 'itunes:author': 'John Doe', + 'itunes:subtitle': 'A short primer on table spices', + 'itunes:image': { + _attr: { + href: 'http://example.com/podcasts/everything/AllAboutEverything/Episode1.jpg' + } + }, + 'itunes:duration': '7:04' + } + }); + + var expectedResult ='\n' + + '' + + '' + + 'title' + + 'description' + + 'http://example.com' + + 'RSS for Node' + + '' + new Date().toUTCString() +'' + + '' + + 'Dylan Greene' + + 'Sun, 20 May 2012 04:00:00 GMT' + + '2013 Dylan Green' + + 'en' + + 'Dylan Green' + + 'Dylan Green' + + 'http://example.com/rss/docs.html' + + '60' + + 'Category 1' + + 'Category 2' + + 'Category 3' + + 'A show about everything' + + 'John Doe' + + 'All About Everything is a show about everything. Each week we dive into any subject known to man and talk about it as much as we can. Look for our podcast in the Podcasts app or in the iTunes Store' + + '' + + 'John Doe' + + 'john.doe@example.com' + + '' + + '' + + '' + + '' + + '' + + '' + + 'item 1' + + 'description 1' + + 'http://example.com/article1' + + 'http://example.com/article1' + + 'Dylan Greene' + + 'Thu, 24 May 2012 04:00:00 GMT' + + 'John Doe' + + 'A short primer on table spices' + + '' + + '7:04' + + '' + + '' + + ''; + var result = feed.xml(); + + expect(result).to.equal(expectedResult); + done(); + }); +});