mirror of
https://github.com/zotero/zotero.git
synced 2026-08-28 05:25:31 +00:00
Use alternate method to test feed check delay
This commit is contained in:
parent
2b7535cd83
commit
d9341bbf1a
2 changed files with 5 additions and 3 deletions
|
|
@ -258,6 +258,9 @@ Zotero.Feeds = new function () {
|
|||
};
|
||||
|
||||
let globalFeedCheckDelay = Promise.resolve();
|
||||
|
||||
this._nextFeedCheckDelay = null; // For tests
|
||||
|
||||
this.scheduleNextFeedCheck = async function () {
|
||||
// Don't schedule if already updating, since another check is scheduled at the end
|
||||
if (_updating) {
|
||||
|
|
@ -280,6 +283,7 @@ Zotero.Feeds = new function () {
|
|||
|
||||
if (nextCheck !== false) {
|
||||
nextCheck = nextCheck > 0 ? nextCheck * 1000 : 0;
|
||||
this._nextFeedCheckDelay = nextCheck;
|
||||
Zotero.debug("Next feed check in " + (nextCheck / 1000) + " seconds");
|
||||
this._nextFeedCheck = setTimeout(async () => {
|
||||
await globalFeedCheckDelay;
|
||||
|
|
|
|||
|
|
@ -224,7 +224,6 @@ describe("Zotero.Feeds", function () {
|
|||
describe('#scheduleNextFeedCheck()', function () {
|
||||
it('schedules next feed check', async function () {
|
||||
sinon.spy(Zotero.Feeds, 'scheduleNextFeedCheck');
|
||||
sinon.spy(Zotero.Promise, 'delay');
|
||||
|
||||
await clearFeeds();
|
||||
let feed = await createFeed({refreshInterval: 1});
|
||||
|
|
@ -234,10 +233,9 @@ describe("Zotero.Feeds", function () {
|
|||
await Zotero.Feeds.scheduleNextFeedCheck();
|
||||
|
||||
// Allow a propagation delay of 5000ms
|
||||
assert.isTrue(Zotero.Promise.delay.args[0][0] - 1000*60*60 <= 5000);
|
||||
assert.isTrue(Zotero.Feeds._nextFeedCheckDelay - 1000 * 60 * 60 <= 5000);
|
||||
|
||||
Zotero.Feeds.scheduleNextFeedCheck.restore();
|
||||
Zotero.Promise.delay.restore();
|
||||
});
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue