Commit d54f9c2d authored by Stefan Penner's avatar Stefan Penner

Merge pull request #83 from teddyzeenny/all-exception

Throw exception in all called without an array
parents 71f121c1 d8d19e41
import { Promise } from "rsvp/promise";
function all(promises) {
if(toString.call(promises) !== "[object Array]") {
throw new TypeError('You must pass an array to all.');
}
return new Promise(function(resolve, reject) {
var results = [], remaining = promises.length,
promise;
......
......@@ -483,6 +483,20 @@ describe("RSVP extensions", function() {
assert(RSVP.all);
});
it('throws when not passed an array', function() {
assert.throws(function () {
var all = RSVP.all();
}, TypeError);
assert.throws(function () {
var all = RSVP.all('');
}, TypeError);
assert.throws(function () {
var all = RSVP.all({});
}, TypeError);
});
specify('fulfilled only after all of the other promises are fulfilled', function(done) {
var firstResolved, secondResolved, firstResolver, secondResolver;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment