blob: 8d0b47343ff908906c74d5b62c5731f62cf64812 (
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
|
/**
* 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/');
});
});
|