diff --git a/test/tests/data/feedCDATA.rss b/test/tests/data/feedCDATA.rss
new file mode 100644
index 0000000000..8809b806ab
--- /dev/null
+++ b/test/tests/data/feedCDATA.rss
@@ -0,0 +1,68 @@
+
+
+
+
+ Science current issue
+ http://science.sciencemag.org
+ Science RSS feed -- current issue
+ 1095-9203
+ May 21 2021 12:00:00:000AM
+ Science
+ 0036-8075
+
+
+
+
+
+
+
+
+
+ Science
+ http://science.sciencemag.org/icons/banner/title.gif
+ http://science.sciencemag.org
+
+ -
+
+ http://science.sciencemag.org/cgi/content/short/372/6544/769?rss=1
+
+
+ 2021-05-20T10:40:55-07:00
+ info:doi/10.1126/science.abj4606
+ hwp:resource-id:sci;372/6544/769
+ American Association for the Advancement of Science
+
+
+ 2021-05-21
+ editorial
+ 372
+ 6544
+ 769
+ 769
+
+ -
+
+ http://science.sciencemag.org/cgi/content/short/372/6544/770?rss=1
+
+
+ 2021-05-20T10:40:55-07:00
+ info:doi/10.1126/science.372.6544.770
+ hwp:resource-id:sci;372/6544/770
+ American Association for the Advancement of Science
+
+
+ 2021-05-21
+ In Brief
+ 372
+ 6544
+ 770
+ 772
+
+
diff --git a/test/tests/data/feedMedia.xml b/test/tests/data/feedMedia.xml
new file mode 100644
index 0000000000..e9452ad740
--- /dev/null
+++ b/test/tests/data/feedMedia.xml
@@ -0,0 +1,31 @@
+
+
+
+
+ NYT > Top Stories
+ https://www.nytimes.com
+
+
+ en-us
+ Copyright 2021 The New York Times Company
+ Wed, 16 Jun 2021 19:30:15 +0000
+ Wed, 16 Jun 2021 19:20:47 +0000
+ -
+ In Pictures: President Biden’s Trip to Europe
+ https://www.nytimes.com/2021/06/10/world/europe/biden-europe-pictures.html
+ https://www.nytimes.com/2021/06/10/world/europe/biden-europe-pictures.html
+
+ The president is in Cornwall, England, to meet with other leaders of wealthy democracies.
+ Wed, 16 Jun 2021 18:53:17 +0000
+ Biden, Joseph R Jr
+ Johnson, Boris
+ Biden, Jill Tracy Jacobs
+ Group of Seven
+ North Atlantic Treaty Organization
+ Coronavirus (2019-nCoV)
+ Europe
+
+ Doug Mills/The New York Times
+
+
+
diff --git a/test/tests/data/feedRichText.rss b/test/tests/data/feedRichText.rss
new file mode 100644
index 0000000000..dd1073b595
--- /dev/null
+++ b/test/tests/data/feedRichText.rss
@@ -0,0 +1,30 @@
+
+
+
+
+ Liftoff News
+ http://liftoff.msfc.nasa.gov/
+ Liftoff to Space Exploration.
+ en-us
+ Tue, 10 Jun 2003 04:00:00 GMT
+ Tue, 10 Jun 2003 09:41:01 GMT
+ http://blogs.law.harvard.edu/tech/rss
+ Weblog Editor 2.0
+ editor@example.com
+ webmaster@example.com
+ -
+ Encoded "entity"
+ http://liftoff.msfc.nasa.gov/news/2003/news-starcity.asp
+ They take a crash course in language & protocol.
+ Tue, 03 Jun 2003 09:39:21 GMT
+ http://liftoff.msfc.nasa.gov/2003/06/03.html#item573
+
+ -
+ Embedded <b>tags</b>
+ http://liftoff.msfc.nasa.gov/news/2003/news-VASIMR.asp
+ The proposed <b>VASIMR</b> engine would do that.
+ Tue, 27 May 2003 08:37:32 GMT
+ http://liftoff.msfc.nasa.gov/2003/05/27.html#item571
+
+
+
diff --git a/test/tests/feedReaderTest.js b/test/tests/feedReaderTest.js
index 6eaceab270..7b34a3efc2 100644
--- a/test/tests/feedReaderTest.js
+++ b/test/tests/feedReaderTest.js
@@ -30,18 +30,10 @@ describe("Zotero.FeedReader", function () {
language: 'en'
};
+ var richTextRSSFeedURL = getTestDataUrl("feedRichText.rss");
+ var cdataRSSFeedURL = getTestDataUrl("feedCDATA.rss");
var atomFeedURL = getTestDataUrl("feed.atom");
- var atomFeedInfo = {
- title: 'Incircular nets and confocal conics',
- updated: new Date("Tue, 10 Jun 2003 09:41:01 GMT"),
- creators: [{
- firstName: '',
- lastName: 'editor@example.com',
- creatorType: 'author',
- fieldMode: 1
- }],
- language: 'en-us'
- };
+ var mediaFeedURL = getTestDataUrl("feedMedia.xml");
after(function* () {
yield clearFeeds();
@@ -200,5 +192,51 @@ describe("Zotero.FeedReader", function () {
while(item = yield itemIterator.next().value);
assert.isNull(item);
});
+
+ it('should decode entities', async () => {
+ const fr = new Zotero.FeedReader(richTextRSSFeedURL);
+ await fr.process();
+ const itemIterator = new fr.ItemIterator();
+ const item = await itemIterator.next().value;
+
+ assert.equal(item.title, `Encoded "entity"`);
+ assert.equal(item.abstractNote, "They take a crash course in language & protocol.");
+ });
+
+ it('should remove tags', async () => {
+ const fr = new Zotero.FeedReader(richTextRSSFeedURL);
+ await fr.process();
+ const itemIterator = new fr.ItemIterator();
+ let item;
+ for (let i = 0; i < 2; i++) {
+ // eslint-disable-next-line no-await-in-loop
+ item = await itemIterator.next().value;
+ }
+
+ // The entry title is text only, so tags are just more text.
+ assert.equal(item.title, "Embedded tags");
+ // The entry description is XHTML, so tags are removed there.
+ assert.equal(item.abstractNote, "The proposed VASIMR engine would do that.");
+ });
+
+ it('should parse CDATA as text', async () => {
+ const fr = new Zotero.FeedReader(cdataRSSFeedURL);
+ await fr.process();
+ const itemIterator = new fr.ItemIterator();
+ const item = await itemIterator.next().value;
+
+ assert.equal(item.title, `"The Descent of Man," 150 years on`);
+ assert.equal(item.creators[0].lastName, "Fuentes");
+ });
+
+ it('should parse enclosed media', async () => {
+ const fr = new Zotero.FeedReader(mediaFeedURL);
+ await fr.process();
+ const itemIterator = new fr.ItemIterator();
+ const item = await itemIterator.next().value;
+
+ assert.equal(item.enclosedItems.length, 1);
+ assert.equal(item.enclosedItems[0].url, "https://static01.nyt.com/images/2021/06/16/world/16biden-photos1/16biden-photos1-moth.jpg");
+ });
});
-})
\ No newline at end of file
+})