Skip to content

Commit

Permalink
Make itemFromCSLJSON independent of Zotero.Item existance.
Browse files Browse the repository at this point in the history
  • Loading branch information
adomasven committed May 8, 2017
1 parent 746171a commit dbeecb9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion chrome/content/zotero/xpcom/utilities.js
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions test/tests/utilitiesTest.js
Expand Up @@ -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 () {
Expand Down

0 comments on commit dbeecb9

Please sign in to comment.