summaryrefslogtreecommitdiffstats
path: root/js/build/tests/services/opmlparserSpec.js
blob: 0b1ce685693c7bf36ce2a0f2655a663785bf0f28 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
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=\
			      "&lt;div&gt;Bret Victor\'s website&lt;/div&gt;"\
			      title="&lt;div&gt;Bret Victor\'s website&lt;/div&gt;"\
			      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);