diff options
author | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-14 00:43:40 +0200 |
---|---|---|
committer | Bernhard Posselt <dev@bernhard-posselt.com> | 2014-09-14 00:43:40 +0200 |
commit | 2647d14cf062c4771b3400721b336bd5857f84f8 (patch) | |
tree | 06b382a41257550d33719b4736ea190d06eb845a /js/tests | |
parent | c67f4bf6075844a558d137f9e4e926a4d5e53d0f (diff) |
add parser for opml
Diffstat (limited to 'js/tests')
-rw-r--r-- | js/tests/unit/service/OPMLParserSpec.js | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/js/tests/unit/service/OPMLParserSpec.js b/js/tests/unit/service/OPMLParserSpec.js new file mode 100644 index 000000000..8d0b47343 --- /dev/null +++ b/js/tests/unit/service/OPMLParserSpec.js @@ -0,0 +1,81 @@ +/** + * ownCloud - News + * + * This file is licensed under the Affero General Public License version 3 or + * later. See the COPYING file. + * + * @author Bernhard Posselt <dev@bernhard-posselt.com> + * @copyright Bernhard Posselt 2014 + */ +describe('OPMLParser', function () { + 'use strict'; + + var result; + + /*jshint multistr: true */ + /*jshint quotmark: double */ + var xml = "<?xml version='1.0' ?> \ + <opml version='1.1'> \ + <head> \ + </head> \ + <body> \ + <outline htmlUrl='http://www.reddit.com/r/tldr/' text='test_text'/> \ + <outline text='Design' title='Tesign'> \ + <outline \ + htmlUrl='http://worrydream.com/' \ + text='yo' \ + title='man' \ + xmlUrl='http://worrydream.com/feed.xml'/> \ + <outline text='Mom' title='Me'> \ + <outline \ + htmlUrl='http://afaikblog.wordpress.com'/> \ + <outline \ + htmlUrl='http://informationarchitects.net' \ + xmlUrl='http://informationarchitects.net/feed/'/> \ + </outline> \ + </outline> \ + <outline text='Nomadism'> \ + <outline \ + htmlUrl='http://a-flat.posterous.com' \ + title='a-flat' \ + xmlUrl='http://a-flat.posterous.com/rss.xml'/> \ + </outline> \ + <outline title='Elezea' text='Elezee' \ + xmlUrl='http://feeds.feedburner.com/elezea'/> \ + </body> \ + </opml>"; + /*jshint quotmark: single */ + + beforeEach(module('News')); + + beforeEach(inject(function (OPMLParser) { + result = OPMLParser.parse(xml); + })); + + + it ('should parse the correct amount of feeds and folders', function () { + expect(result.folders.length).toBe(2); + expect(result.feeds.length).toBe(2); + expect(result.folders[0].feeds.length).toBe(3); + expect(result.folders[1].feeds.length).toBe(1); + }); + + + it ('should default to title for feeds and folders', function () { + expect(result.folders[0].name).toBe('Tesign'); + expect(result.folders[1].name).toBe('Nomadism'); + expect(result.feeds[0].name).toBe('test_text'); + expect(result.feeds[1].name).toBe('Elezea'); + }); + + + it ('should default to url for feeds if no title or text', function () { + expect(result.folders[0].feeds[0].name).toBe('man'); + expect(result.folders[0].feeds[1].name).toBe( + 'http://afaikblog.wordpress.com'); + expect(result.folders[0].feeds[2].name).toBe( + 'http://informationarchitects.net/feed/'); + }); + + +}); |