diff --git a/test/rss.test.js b/test/rss.test.js index 520441e..c50ef81 100644 --- a/test/rss.test.js +++ b/test/rss.test.js @@ -359,4 +359,104 @@ describe('rss module', function(done) { expect(result).to.equal(expectedResult); done(); }); + + it('should work with custom namespaces', 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', + pubDate: 'May 20, 2012 04:00:00 GMT', + language: 'en', + ttl: '60', + customNamespaces: { + 'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd' + }, + 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'+ + ''+ + '' + + '<![CDATA[title]]>' + + '' + + 'http://example.com' + + 'RSS for Node' + + '' + new Date().toUTCString() +'' + + '' + + '' + + 'Sun, 20 May 2012 04:00:00 GMT' + + '' + + '60' + + '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' + + '' + + '' + + '' + + '' + + '' + + '' + + '<![CDATA[item 1]]>' + + '' + + 'http://example.com/article1' + + 'http://example.com/article1' + + '' + + '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(); + }); });