Various feeds changes

- Hide notes, tags and related for feed items in itembox
- Add feed support for <enclosure> elements
- Add feed syncing methods for synced settings (additional work is
  needed on the sync architecture to download synced settings from the
  server)
- Change feed item clear policy to be less aggressive
- Adjust for deasyncification
- Disable translate-on-select
- Close adomasven/zotero#7, Remove context menu items from feeds
This commit is contained in:
Adomas Venčkauskas 2016-02-11 11:02:38 +00:00 committed by Dan Stillman
parent 0d4025e9fb
commit 12fc6cfbe8
42 changed files with 894 additions and 379 deletions

View file

@ -3,6 +3,77 @@ describe("Zotero.Feeds", function () {
after(function* () {
yield clearFeeds();
});
describe("#restoreFromJSON", function() {
var json = {};
var expiredFeedURL, existingFeedURL;
before(function() {
sinon.stub(Zotero.Feed.prototype, 'updateFeed').resolves();
});
after(function() {
Zotero.Feed.prototype.updateFeed.restore();
});
beforeEach(function* () {
yield clearFeeds();
for (let i = 0; i < 2; i++) {
let url = "http://" + Zotero.Utilities.randomString(10, 'abcdefgh') + ".com/feed.rss";
json[url] = {
url,
name: Zotero.Utilities.randomString(),
refreshInterval: 5,
cleanupAfter: 3,
markedAsRead: []
};
if (i == 0) {
existingFeedURL = url;
yield createFeed({url});
}
}
expiredFeedURL = (yield createFeed()).url;
});
it("restores correctly when merge is true", function* () {
let feeds = Zotero.Feeds.getAll();
assert.equal(feeds.length, 2);
yield Zotero.Feeds.restoreFromJSON(json, true);
feeds = Zotero.Feeds.getAll();
for (let url in json) {
let feed = Zotero.Feeds.getByURL(url);
assert.ok(feed, "new feed created");
}
let expiredFeed = Zotero.Feeds.getByURL(expiredFeedURL);
assert.ok(expiredFeed, "does not remove feeds not in JSON");
let existingFeed = Zotero.Feeds.getByURL(existingFeedURL);
assert.ok(existingFeed, "does not remove feeds in database and JSON");
});
it("restores correctly when merge is false", function* () {
let feeds = Zotero.Feeds.getAll();
assert.equal(feeds.length, 2);
yield Zotero.Feeds.restoreFromJSON(json);
feeds = Zotero.Feeds.getAll();
for (let url in json) {
let feed = Zotero.Feeds.getByURL(url);
assert.ok(feed, "new feed created");
}
let expiredFeed = Zotero.Feeds.getByURL(expiredFeedURL);
assert.notOk(expiredFeed, "removes feeds not in JSON");
let existingFeed = Zotero.Feeds.getByURL(existingFeedURL);
assert.ok(existingFeed, "does not remove feeds in database and JSON");
});
});
describe("#haveFeeds()", function() {
it("should return false for a DB without feeds", function* () {
@ -40,6 +111,23 @@ describe("Zotero.Feeds", function () {
assert.sameMembers(feeds, [feed1, feed2]);
});
});
describe('#getByURL', function() {
it("should return a feed by url", function* () {
let url = 'http://' + Zotero.Utilities.randomString(10, 'abcdefg') + '.com/feed.rss';
yield createFeed({url});
let feed = Zotero.Feeds.getByURL(url);
assert.ok(feed);
assert.equal(feed.url, url);
});
it("should return undefined if feed does not exist", function* () {
var feed;
assert.doesNotThrow(function() {
feed = Zotero.Feeds.getByURL('doesnotexist');
});
assert.isUndefined(feed);
});
});
describe('#updateFeeds', function() {
var freshFeed, recentFeed, oldFeed;
var _updateFeed;
@ -49,7 +137,7 @@ describe("Zotero.Feeds", function () {
sinon.stub(Zotero.Feeds, 'scheduleNextFeedCheck');
_updateFeed = sinon.stub(Zotero.Feed.prototype, '_updateFeed').resolves();
let url = getTestDataItemUrl("feed.rss");
let url = getTestDataUrl("feed.rss");
freshFeed = yield createFeed({refreshInterval: 2});
freshFeed._feedUrl = url;
@ -97,7 +185,7 @@ describe("Zotero.Feeds", function () {
break;
}
// should never reach
assert.isOk(null, "does not update feed that did not need updating")
assert.ok(null, "does not update feed that did not need updating")
}
});
});