commit 2237c71dcbaf52b8b51543febe419ea2f88234bf
parent 33deefbf74dd96c082d0950c2f927a8befbe88fc
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 17 Jan 2017 04:18:39 -0500
Fix test for invalid id passed to DataObjects.getAsync()
Diffstat:
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
@@ -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
@@ -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) {