Make Zotero.DataObject#fromJSON() synchronous
When called on an identified object (i.e., one with an id or library/key), loadAllData() must be called first. When called on a new object (which is more common anyway), fromJSON() can be called immediately.
This commit is contained in:
parent
5d8670db1d
commit
7d8a1b2573
4 changed files with 25 additions and 18 deletions
|
@ -954,7 +954,7 @@ describe("Zotero.Item", function () {
|
|||
dateModified: "2015-06-07T20:58:00Z",
|
||||
};
|
||||
var item = new Zotero.Item;
|
||||
yield item.fromJSON(json);
|
||||
item.fromJSON(json);
|
||||
assert.equal(item.getField('accessDate'), '2015-06-07 20:56:00');
|
||||
assert.equal(item.dateAdded, '2015-06-07 20:57:00');
|
||||
assert.equal(item.dateModified, '2015-06-07 20:58:00');
|
||||
|
@ -968,7 +968,7 @@ describe("Zotero.Item", function () {
|
|||
dateModified: "2015-06-07 20:58:00",
|
||||
};
|
||||
var item = new Zotero.Item;
|
||||
yield item.fromJSON(json);
|
||||
item.fromJSON(json);
|
||||
assert.strictEqual(item.getField('accessDate'), '');
|
||||
// DEBUG: Should these be null, or empty string like other fields from getField()?
|
||||
assert.isNull(item.dateAdded);
|
||||
|
@ -992,14 +992,14 @@ describe("Zotero.Item", function () {
|
|||
};
|
||||
|
||||
var item = new Zotero.Item;
|
||||
yield item.fromJSON(json);
|
||||
item.fromJSON(json);
|
||||
var id = yield item.saveTx();
|
||||
assert.sameDeepMembers(item.getCreatorsJSON(), json.creators);
|
||||
})
|
||||
|
||||
it("should map a base field to an item-specific field", function* () {
|
||||
var item = new Zotero.Item("bookSection");
|
||||
yield item.fromJSON({
|
||||
item.fromJSON({
|
||||
"itemType":"bookSection",
|
||||
"publicationTitle":"Publication Title"
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue