diff options
Diffstat (limited to 'js/build/tests/services/opmlparserSpec.js')
-rw-r--r-- | js/build/tests/services/opmlparserSpec.js | 167 |
1 files changed, 167 insertions, 0 deletions
diff --git a/js/build/tests/services/opmlparserSpec.js b/js/build/tests/services/opmlparserSpec.js new file mode 100644 index 000000000..0b1ce6856 --- /dev/null +++ b/js/build/tests/services/opmlparserSpec.js @@ -0,0 +1,167 @@ +// Generated by CoffeeScript 1.6.3 +/* + +ownCloud - News + +@author Raghu Nayyar +@copyright 2012 Raghu Nayyar me@iraghu.com + +This library is free software; you can redistribute it and/or +modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE +License as published by the Free Software Foundation; either +version 3 of the License, or any later version. + +This library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU AFFERO GENERAL PUBLIC LICENSE for more details. + +You should have received a copy of the GNU Affero General Public +License along with this library. If not, see <http://www.gnu.org/licenses/>. +*/ + + +(function() { + describe('OPMLParser', function() { + var _this = this; + beforeEach(module('News')); + beforeEach(inject(function(OPMLParser) { + _this.OPMLParser = OPMLParser; + _this.opml = '<?xml version="1.0" ?>\ + <opml version="1.1">\ + <!--Generated by NewsBlur - www.newsblur.com-->\ + <head>\ + <title>\ + NewsBlur Feeds\ + </title>\ + <dateCreated>\ + 2013-03-14 16:44:01.356965\ + </dateCreated>\ + <dateModified>\ + 2013-03-14 16:44:01.356965\ + </dateModified>\ + </head>\ + <body>\ + <outline htmlUrl="http://www.reddit.com/r/tldr/"\ + text="test_text" type="rss" version="RSS"\ + xmlUrl="http://www.reddit.com/r/tldr.rss"/>\ + \ + <outline htmlUrl="http://news.ycombinator.com"\ + text="Hacker News 200" title="Hacker News 200" type="rss"\ + version="RSS"\ + xmlUrl=\ + "http://feeds.feedburner.com/hacker-news-feed-200?format=xml"/>\ + \ + <outline text="Design" title="Design">\ + <outline htmlUrl="http://worrydream.com/" text=\ + "<div>Bret Victor\'s website</div>"\ + title="<div>Bret Victor\'s website</div>"\ + type="rss"\ + version="RSS" xmlUrl="http://worrydream.com/feed.xml"/>\ + \ + <outline htmlUrl="http://www.hylkebons.nl/journal/rss/" text=\ + "Journal - Hylke Bons"\ + title="Journal - Hylke Bons"\ + type="rss"\ + version="RSS" xmlUrl="http://feeds.feedburner.com/HbonsHome"/>\ + \ + <outline htmlUrl="http://afaikblog.wordpress.com" text=\ + "As far as I know"\ + title="As far as I know"\ + type="rss"\ + version="RSS" xmlUrl="https://afaikblog.wordpress.com/feed/"/>\ + \ + <outline htmlUrl="http://informationarchitects.net" text=\ + "Information Architects"\ + title="Information Architects"\ + type="rss"\ + version="RSS" xmlUrl="http://informationarchitects.net/feed/"/>\ + \ + <outline htmlUrl="http://ignorethecode.net" text=\ + "ignorethecode.net"\ + title="ignorethecode.net"\ + type="rss"\ + version="RSS"\ + xmlUrl="http://feeds.feedburner.com/IgnoreTheCode"/>\ + \ + <outline htmlUrl="http://blogs.gnome.org/mccann" text=\ + "Push the Button"\ + title="Push the Button"\ + type="rss"\ + version="RSS" xmlUrl="https://blogs.gnome.org/mccann/feed/"/>\ + \ + <outline htmlUrl="http://littlebigdetails.com/" text=\ + "Little Big Details"\ + title="Little Big Details"\ + type="rss"\ + version="RSS"\ + xmlUrl="http://feeds.feedburner.com/littlebigdetails"/>\ + \ + <outline htmlUrl="http://theixdlibrary.com" text=\ + "The IxD Library"\ + title="The IxD Library" type="rss"\ + version="RSS" xmlUrl="http://theixdlibrary.com/feed/"/>\ + </outline>\ +\ + <outline text="Nomadism" title="Nomadism">\ + \ + <outline htmlUrl="http://a-flat.posterous.com"\ + text="a-flat" title="a-flat" type="rss"\ + version="RSS" xmlUrl="http://a-flat.posterous.com/rss.xml"/>\ +\ + <outline htmlUrl="http://egor.im"\ + text="egor.im" title="egor.im" type="rss"\ + version="RSS" xmlUrl="http://feeds.feedburner.com/egorim"/>\ + \ + <outline htmlUrl="http://nomadbase.org/"\ + text="nomadbase - find the others..."\ + title="nomadbase - find the others..." type="rss"\ + version="RSS" xmlUrl="http://nomadbase.org/rss.xml"/>\ + \ + <outline htmlUrl="http://casarobino.org/frontpage"\ + text="Casa Robino - Shared Hospitality"\ + title="Casa Robino - Shared Hospitality" type="rss"\ + version="RSS" xmlUrl="http://casarobino.org/rss.xml"/>\ + \ + <outline htmlUrl="http://casabhavani.org"\ + text="Casa Bhavani" title="Casa Bhavani" type="rss"\ + version="RSS" xmlUrl="http://casabhavani.org/feed/"/>\ +\ + </outline>\ + \ + <outline htmlUrl="http://www.elezea.com"\ + text="Elezea" title="Elezea" type="rss"\ + version="RSS" xmlUrl="http://feeds.feedburner.com/elezea"/>\ +\ + </body>\ + </opml>'; + return _this.data = _this.OPMLParser.parseXML(_this.opml); + })); + it('should return only the root folder when parsing empty OPML', function() { + var data; + data = _this.OPMLParser.parseXML(''); + return expect(data.getName()).toBe('root'); + }); + it('should parse folders', function() { + var firstLevel; + firstLevel = _this.data.getItems(); + expect(firstLevel[2].isFolder()).toBe(true); + return expect(firstLevel[2].getName()).toBe('Design'); + }); + it('should parse feeds', function() { + var firstLevel; + firstLevel = _this.data.getItems()[0]; + expect(firstLevel.isFolder()).toBe(false); + expect(firstLevel.getUrl()).toBe('http://www.reddit.com/r/tldr.rss'); + return expect(firstLevel.getName()).toBe('test_text'); + }); + return it('should nest feeds', function() { + var secondLevel; + secondLevel = _this.data.getItems()[2].getItems()[1]; + expect(secondLevel.isFolder()).toBe(false); + expect(secondLevel.getUrl()).toBe('http://feeds.feedburner.com/HbonsHome'); + return expect(secondLevel.getName()).toBe('Journal - Hylke Bons'); + }); + }); + +}).call(this); |