Don't auto-sync skipped libraries on change
This commit is contained in:
parent
599598566b
commit
cd3f621a00
2 changed files with 54 additions and 2 deletions
48
test/tests/syncEventListenersTest.js
Normal file
48
test/tests/syncEventListenersTest.js
Normal file
|
@ -0,0 +1,48 @@
|
|||
"use strict";
|
||||
|
||||
describe("Zotero.Sync.EventListeners", function () {
|
||||
describe("AutoSyncListener", function () {
|
||||
var originalTimeout;
|
||||
|
||||
before(function () {
|
||||
originalTimeout = Zotero.Sync.EventListeners.AutoSyncListener._editTimeout;
|
||||
assert.ok(originalTimeout);
|
||||
// Set timeout to 1ms
|
||||
Zotero.Sync.EventListeners.AutoSyncListener._editTimeout = 0.001;
|
||||
Zotero.Prefs.set('sync.autoSync', true);
|
||||
});
|
||||
|
||||
|
||||
after(function () {
|
||||
Zotero.Sync.EventListeners.AutoSyncListener._editTimeout = originalTimeout;
|
||||
Zotero.Prefs.set('sync.autoSync', false);
|
||||
Zotero.Prefs.clear('sync.librariesToSkip');
|
||||
});
|
||||
|
||||
|
||||
it("should sync only changed library", function* () {
|
||||
var mock = sinon.mock(Zotero.Sync.Runner);
|
||||
var expectation = mock.expects("setSyncTimeout").once();
|
||||
|
||||
var group = yield createGroup();
|
||||
yield createDataObject('item', { libraryID: group.libraryID });
|
||||
|
||||
yield Zotero.Promise.delay(10);
|
||||
mock.verify();
|
||||
assert.sameMembers(expectation.getCall(0).args[2].libraries, [group.libraryID]);
|
||||
});
|
||||
|
||||
|
||||
it("shouldn't sync skipped library", function* () {
|
||||
var mock = sinon.mock(Zotero.Sync.Runner);
|
||||
var expectation = mock.expects("setSyncTimeout").never();
|
||||
|
||||
var group = yield createGroup();
|
||||
Zotero.Prefs.set('sync.librariesToSkip', JSON.stringify(["L" + group.libraryID]));
|
||||
yield createDataObject('item', { libraryID: group.libraryID });
|
||||
|
||||
yield Zotero.Promise.delay(10);
|
||||
mock.verify();
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue