Close adomasven/zotero#11. Add support for feed imports from OPML files

This commit is contained in:
Adomas Venčkauskas 2016-04-20 15:09:31 +01:00
parent 3dabd63a0a
commit 3b758e562b
9 changed files with 119 additions and 2 deletions

View file

@ -4,6 +4,39 @@ describe("Zotero.Feeds", function () {
yield clearFeeds();
});
describe('#importFromOPML', function() {
var opmlUrl = getTestDataUrl("feeds.opml");
var opmlString;
before(function* (){
opmlString = yield Zotero.File.getContentsFromURLAsync(opmlUrl)
});
beforeEach(function* () {
yield clearFeeds();
});
it('imports feeds correctly', function* (){
let shouldExist = {
"http://example.com/feed1.rss": "A title 1",
"http://example.com/feed2.rss": "A title 2",
"http://example.com/feed3.rss": "A title 3",
"http://example.com/feed4.rss": "A title 4"
}; yield Zotero.Feeds.importFromOPML(opmlString);
let feeds = Zotero.Feeds.getAll();
for (let feed of feeds) {
assert.equal(shouldExist[feed.url], feed.name, "Feed exists and title matches");
delete shouldExist[feed.url];
}
assert.equal(Object.keys(shouldExist).length, 0, "All feeds from opml have been created");
});
it("doesn't fail if some feeds already exist", function* (){
yield createFeed({url: "http://example.com/feed1.rss"});
yield Zotero.Feeds.importFromOPML(opmlString)
});
});
describe("#restoreFromJSON", function() {
var json = {};
var expiredFeedURL, existingFeedURL;