Skip to content

Commit 0cbbc99

Browse files
Add test for subtitle field parsing in feed and items
- Add test input file (subtitle.rss) with subtitle fields at both feed and item levels - Add expected output file (subtitle.json) with parsed subtitle values - Add test case in parser.js to verify subtitle field parsing
1 parent c3b82f9 commit 0cbbc99

3 files changed

Lines changed: 63 additions & 0 deletions

File tree

test/input/subtitle.rss

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<rss version="2.0">
3+
<channel>
4+
<title>Example Blog</title>
5+
<link>https://example.com/blog</link>
6+
<description>A blog about technology and programming</description>
7+
<subtitle>Tech insights and tutorials</subtitle>
8+
<language>en-us</language>
9+
<lastBuildDate>Mon, 15 Jan 2024 10:00:00 GMT</lastBuildDate>
10+
<item>
11+
<title>First Post</title>
12+
<subtitle>An introduction to our blog</subtitle>
13+
<link>https://example.com/blog/post-1</link>
14+
<description>Welcome to our blog!</description>
15+
<pubDate>Mon, 15 Jan 2024 10:00:00 GMT</pubDate>
16+
<guid>https://example.com/blog/post-1</guid>
17+
</item>
18+
<item>
19+
<title>Second Post</title>
20+
<subtitle>More content for readers</subtitle>
21+
<link>https://example.com/blog/post-2</link>
22+
<description>Here is another post.</description>
23+
<pubDate>Sun, 14 Jan 2024 09:00:00 GMT</pubDate>
24+
<guid>https://example.com/blog/post-2</guid>
25+
</item>
26+
</channel>
27+
</rss>

test/output/subtitle.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"feed": {
3+
"items": [
4+
{
5+
"title": "First Post",
6+
"subtitle": "An introduction to our blog",
7+
"link": "https://example.com/blog/post-1",
8+
"pubDate": "Mon, 15 Jan 2024 10:00:00 GMT",
9+
"content": "Welcome to our blog!",
10+
"contentSnippet": "Welcome to our blog!",
11+
"guid": "https://example.com/blog/post-1",
12+
"isoDate": "2024-01-15T10:00:00.000Z"
13+
},
14+
{
15+
"title": "Second Post",
16+
"subtitle": "More content for readers",
17+
"link": "https://example.com/blog/post-2",
18+
"pubDate": "Sun, 14 Jan 2024 09:00:00 GMT",
19+
"content": "Here is another post.",
20+
"contentSnippet": "Here is another post.",
21+
"guid": "https://example.com/blog/post-2",
22+
"isoDate": "2024-01-14T09:00:00.000Z"
23+
}
24+
],
25+
"title": "Example Blog",
26+
"description": "A blog about technology and programming",
27+
"subtitle": "Tech insights and tutorials",
28+
"link": "https://example.com/blog",
29+
"language": "en-us",
30+
"lastBuildDate": "Mon, 15 Jan 2024 10:00:00 GMT"
31+
}
32+
}

test/parser.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,4 +284,8 @@ describe('Parser', function() {
284284
it('should parse atom:link pagination links', function (done) {
285285
testParseForFile('pagination-links', 'rss', done);
286286
});
287+
288+
it('should parse subtitle field in feed and items', function(done) {
289+
testParseForFile('subtitle', 'rss', done);
290+
});
287291
})

0 commit comments

Comments
 (0)