From 2237c71dcbaf52b8b51543febe419ea2f88234bf Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Tue, 17 Jan 2017 04:18:39 -0500 Subject: [PATCH] Fix test for invalid id passed to DataObjects.getAsync() --- chrome/content/zotero/xpcom/data/dataObjects.js | 4 ++-- test/tests/dataObjectsTest.js | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/data/dataObjects.js b/chrome/content/zotero/xpcom/data/dataObjects.js index 1b399ca9de..a95f9cf25f 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 448d51cb82..3cf9397abd 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) {