Output 'deleted' as 1 instead of true in item JSON

Good idea? Not sure, but that's what the API does.
This commit is contained in:
Dan Stillman 2015-10-30 19:06:29 -04:00
parent 6993ca252c
commit c2ad4ceb0a
2 changed files with 16 additions and 2 deletions

View file

@ -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);

View file

@ -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);
})
})