###
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 .
###
describe 'OPMLParser', ->
beforeEach module 'News'
beforeEach inject (@OPMLParser) =>
@opml = '
NewsBlur Feeds
2013-03-14 16:44:01.356965
2013-03-14 16:44:01.356965
'
@data = @OPMLParser.parseXML(@opml)
it 'should return only the root folder when parsing empty OPML', =>
data = @OPMLParser.parseXML('')
expect(data.getName()).toBe('root')
it 'should parse folders', =>
firstLevel = @data.getItems()
expect(firstLevel[2].isFolder()).toBe(true)
expect(firstLevel[2].getName()).toBe('Design')
it 'should parse feeds', =>
firstLevel = @data.getItems()[0]
expect(firstLevel.isFolder()).toBe(false)
expect(firstLevel.getUrl()).toBe('http://www.reddit.com/r/tldr.rss')
expect(firstLevel.getName()).toBe('test_text')
it 'should nest feeds', =>
secondLevel = @data.getItems()[2].getItems()[1]
expect(secondLevel.isFolder()).toBe(false)
expect(secondLevel.getUrl()).
toBe('http://feeds.feedburner.com/HbonsHome')
expect(secondLevel.getName()).toBe('Journal - Hylke Bons')