Make itemFromCSLJSON independent of Zotero.Item existance.
Addresses !zotero/zotero-connectors#121"
This commit is contained in:
parent
746171ab78
commit
dbeecb9b0a
2 changed files with 14 additions and 1 deletions
|
@ -1815,7 +1815,7 @@ Zotero.Utilities = {
|
|||
* @param {Object} cslItem
|
||||
*/
|
||||
"itemFromCSLJSON":function(item, cslItem) {
|
||||
var isZoteroItem = item instanceof Zotero.Item,
|
||||
var isZoteroItem = !!item.setType,
|
||||
zoteroType;
|
||||
|
||||
// Some special cases to help us map item types correctly
|
||||
|
|
|
@ -384,6 +384,19 @@ describe("Zotero.Utilities", function() {
|
|||
|
||||
assert.equal(item.getField('title'), jsonAttachment.title, 'title imported correctly');
|
||||
});
|
||||
// For Zotero.Item created in translation sandbox in connectors
|
||||
it("should not depend on Zotero.Item existing", function* () {
|
||||
let item = new Zotero.Item;
|
||||
var Item = Zotero.Item;
|
||||
delete Zotero.Item;
|
||||
assert.throws(() => "" instanceof Zotero.Item);
|
||||
|
||||
let data = loadSampleData('citeProcJSExport');
|
||||
assert.doesNotThrow(Zotero.Utilities.itemFromCSLJSON.bind(Zotero.Utilities, item, Object.values(data)[0]));
|
||||
|
||||
Zotero.Item = Item;
|
||||
assert.doesNotThrow(() => "" instanceof Zotero.Item);
|
||||
})
|
||||
});
|
||||
|
||||
describe("#ellipsize()", function () {
|
||||
|
|
Loading…
Add table
Reference in a new issue