diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index 1b399ca9d..a95f9cf25 100644 --- a/chrome/content/zotero/xpcom/data/dataObjects.js +++ b/chrome/content/zotero/xpcom/data/dataObjects.js @@ -177,8 +177,8 @@ Zotero.DataObjects.prototype.getAsync = Zotero.Promise.coroutine(function* (ids, toReturn.push(this._objectCache[id]); } else { - if (!ids.every(id => Number.isInteger(id))) { - throw new Error(`Invalid ${this._ZDO_object} ID '${id}'`); + if (!Number.isInteger(id)) { + throw new Error(`Invalid ${this._ZDO_object} ID '${id}' (${typeof id})`); } toLoad.push(id); } diff --git a/test/tests/dataObjectsTest.js b/test/tests/dataObjectsTest.js index 448d51cb8..3cf9397ab 100644 --- a/test/tests/dataObjectsTest.js +++ b/test/tests/dataObjectsTest.js @@ -9,6 +9,14 @@ describe("Zotero.DataObjects", function () { }); }); + describe("#getAsync()", function () { + it("show throw if passed an invalid id", function* () { + var e = yield getPromiseError(Zotero.Items.getAsync("[Object]")); + assert.ok(e); + assert.include(e.message, '(string)'); + }); + }); + describe("#getLibraryAndKeyFromID()", function () { it("should return a libraryID and key within a transaction", function* () { for (let type of types) {