diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-04-10 13:46:57 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-04-10 13:46:57 +0100 |
| commit | 83ac75808b14862531b046f51f90014d7dea621e (patch) | |
| tree | c5a08546bf69da3809bbb633c9395e58428e9d03 | |
| parent | 0c131afbe82cedeef9815d11428414d6dc663ae7 (diff) | |
Fix error when a zip file cannot be opened
| -rw-r--r-- | browser/unzip.js | 2 | ||||
| -rw-r--r-- | lib/promises.js | 1 | ||||
| -rw-r--r-- | tests/unzip.tests.js | 14 |
3 files changed, 16 insertions, 1 deletions
diff --git a/browser/unzip.js b/browser/unzip.js index 50cbf28..2395fb3 100644 --- a/browser/unzip.js +++ b/browser/unzip.js @@ -8,7 +8,7 @@ function openZip(options) { if (options.arrayBuffer) { return openArrayBuffer(options.arrayBuffer); } else { - return q.reject(new Error("Could not find file in options")); + return promises.reject(new Error("Could not find file in options")); } } diff --git a/lib/promises.js b/lib/promises.js index 2dfc77a..32371c1 100644 --- a/lib/promises.js +++ b/lib/promises.js @@ -5,6 +5,7 @@ exports.defer = bluebird.defer; exports.when = bluebird.resolve; exports.resolve = bluebird.resolve; exports.all = bluebird.all; +exports.reject = bluebird.reject; exports.nfcall = function(func) { var args = Array.prototype.slice.call(arguments, 1); diff --git a/tests/unzip.tests.js b/tests/unzip.tests.js new file mode 100644 index 0000000..95aa26f --- /dev/null +++ b/tests/unzip.tests.js @@ -0,0 +1,14 @@ +var assert = require("assert"); + +var test = require("./testing").test; +var unzip = require("../lib/unzip"); + +describe("unzip", function() { + test("unzip fails if given empty object", function() { + return unzip.openZip({}).then(function() { + assert.ok(false, "Expected failure"); + }, function(error) { + assert.equal("Could not find file in options", error.message); + }); + }); +}); |
