Functions to modify 'version'/'synced' efficiently, plus some other fixes

This commit is contained in:
Dan Stillman 2015-05-21 21:56:04 -04:00
parent cf3eed5f14
commit ada657fcb8
6 changed files with 184 additions and 25 deletions

View file

@ -37,7 +37,6 @@ describe("Zotero.DataObject", function() {
it("should be set after creating object", function* () {
for (let type of types) {
Zotero.logError(type);
let obj = yield createDataObject(type, { version: 1234 });
assert.equal(obj.version, 1234, type + " version mismatch");
yield obj.eraseTx();
@ -126,4 +125,50 @@ describe("Zotero.DataObject", function() {
assert.equal(objectsClass.getIDFromLibraryAndKey(libraryID, key), id);
})
})
describe("#updateVersion()", function() {
it("should update the object version", function* () {
for (let type of types) {
let obj = yield createDataObject(type);
assert.equal(obj.version, 0);
yield obj.updateVersion(1234);
assert.equal(obj.version, 1234);
assert.isFalse(obj.hasChanged());
obj.synced = true;
assert.ok(obj.hasChanged());
yield obj.updateVersion(1235);
assert.equal(obj.version, 1235);
assert.ok(obj.hasChanged());
yield obj.eraseTx();
}
})
})
describe("#updateSynced()", function() {
it("should update the object sync status", function* () {
for (let type of types) {
let obj = yield createDataObject(type);
assert.isFalse(obj.synced);
yield obj.updateSynced(false);
assert.isFalse(obj.synced);
assert.isFalse(obj.hasChanged());
yield obj.updateSynced(true);
assert.ok(obj.synced);
assert.isFalse(obj.hasChanged());
obj.version = 1234;
assert.ok(obj.hasChanged());
yield obj.updateSynced(false);
assert.isFalse(obj.synced);
assert.ok(obj.hasChanged());
yield obj.eraseTx();
}
})
})
})