Fix test for invalid id passed to DataObjects.getAsync()

This commit is contained in:
Dan Stillman 2017-01-17 04:18:39 -05:00
parent 33deefbf74
commit 2237c71dcb
2 changed files with 10 additions and 2 deletions

View file

@ -177,8 +177,8 @@ Zotero.DataObjects.prototype.getAsync = Zotero.Promise.coroutine(function* (ids,
toReturn.push(this._objectCache[id]); toReturn.push(this._objectCache[id]);
} }
else { else {
if (!ids.every(id => Number.isInteger(id))) { if (!Number.isInteger(id)) {
throw new Error(`Invalid ${this._ZDO_object} ID '${id}'`); throw new Error(`Invalid ${this._ZDO_object} ID '${id}' (${typeof id})`);
} }
toLoad.push(id); toLoad.push(id);
} }

View file

@ -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 () { describe("#getLibraryAndKeyFromID()", function () {
it("should return a libraryID and key within a transaction", function* () { it("should return a libraryID and key within a transaction", function* () {
for (let type of types) { for (let type of types) {