Item.toJSON() should output unset mtime/md5 as null, not undefined
This commit is contained in:
parent
84a6ea18f6
commit
8933e3b586
2 changed files with 14 additions and 2 deletions
|
@ -3905,8 +3905,8 @@ Zotero.Item.prototype.toJSON = Zotero.Promise.coroutine(function* (options = {})
|
|||
}
|
||||
|
||||
if (this.isFileAttachment()) {
|
||||
obj.md5 = yield this.attachmentHash;
|
||||
obj.mtime = yield this.attachmentModificationTime;
|
||||
obj.mtime = (yield this.attachmentModificationTime) || null;
|
||||
obj.md5 = (yield this.attachmentHash) || null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -873,6 +873,18 @@ describe("Zotero.Item", function () {
|
|||
|
||||
assert.strictEqual(json.deleted, 1);
|
||||
})
|
||||
|
||||
it("should output unset storage properties as null", function* () {
|
||||
var item = new Zotero.Item('attachment');
|
||||
item.attachmentLinkMode = 'imported_file';
|
||||
item.fileName = 'test.txt';
|
||||
var id = yield item.saveTx();
|
||||
var json = yield item.toJSON();
|
||||
|
||||
Zotero.debug(json);
|
||||
assert.isNull(json.mtime);
|
||||
assert.isNull(json.md5);
|
||||
})
|
||||
})
|
||||
|
||||
describe("'full' mode", function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue