commit c2ad4ceb0a1f18faf4d2cad48d0c39c1ba10893b
parent 6993ca252c5792380e3de0aff8b262818b14214d
Author: Dan Stillman <dstillman@zotero.org>
Date: Fri, 30 Oct 2015 19:06:29 -0400
Output 'deleted' as 1 instead of true in item JSON
Good idea? Not sure, but that's what the API does.
Diffstat:
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/chrome/content/zotero/xpcom/data/item.js b/chrome/content/zotero/xpcom/data/item.js
@@ -3934,7 +3934,7 @@ Zotero.Item.prototype.toJSON = Zotero.Promise.coroutine(function* (options = {})
// Deleted
let deleted = this.deleted;
if (deleted || mode == 'full') {
- obj.deleted = deleted;
+ obj.deleted = deleted ? 1 : 0;
}
obj.dateAdded = Zotero.Date.sqlToISO8601(this.dateAdded);
diff --git a/test/tests/itemTest.js b/test/tests/itemTest.js
@@ -859,6 +859,20 @@ describe("Zotero.Item", function () {
assert.isUndefined(json.date);
assert.isUndefined(json.numPages);
})
+
+ it("should output 'deleted' as 1", function* () {
+ var itemType = "book";
+ var title = "Test";
+
+ var item = new Zotero.Item(itemType);
+ item.setField("title", title);
+ item.deleted = true;
+ var id = yield item.saveTx();
+ item = yield Zotero.Items.getAsync(id);
+ var json = yield item.toJSON();
+
+ assert.strictEqual(json.deleted, 1);
+ })
})
describe("'full' mode", function () {
@@ -931,7 +945,7 @@ describe("Zotero.Item", function () {
patchBase: patchBase
})
assert.isUndefined(json.title);
- assert.isTrue(json.deleted);
+ assert.strictEqual(json.deleted, 1);
})
})