Skip to content

Commit

Permalink
Fixing issue #8
Browse files Browse the repository at this point in the history
  • Loading branch information
mzabriskie committed Sep 16, 2014
1 parent 1fa35ce commit 59eb2b6
Show file tree
Hide file tree
Showing 10 changed files with 50 additions and 9 deletions.
4 changes: 3 additions & 1 deletion dist/axios.amd.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/axios.amd.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/axios.amd.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/axios.amd.min.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion dist/axios.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/axios.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/axios.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/axios.min.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion lib/axios.js
Expand Up @@ -51,7 +51,9 @@ var axios = module.exports = function axios(config) {
axios.defaults = defaults;

// Expose all/spread
axios.all = Promise.all;
axios.all = function (promises) {
return Promise.all(promises);
};
axios.spread = spread;

// Provide aliases for supported request methods
Expand Down
35 changes: 35 additions & 0 deletions test/specs/promise.spec.js
Expand Up @@ -67,4 +67,39 @@ describe('promise', function () {
expect(config.url).toEqual('/foo');
});
});

it('should support all', function () {
var fulfilled = false;

axios.all([true, 123]).then(function () {
fulfilled = true;
});

waitsFor(function () {
return fulfilled;
});

runs(function () {
expect(fulfilled).toEqual(true);
});
});

it('should support spread', function () {
var sum = 0;
var fulfilled = false;

axios.all([123, 456]).then(axios.spread(function (a, b) {
sum = a + b;
fulfilled = true;
}));

waitsFor(function () {
return fulfilled;
});

runs(function () {
expect(fulfilled).toEqual(true);
expect(sum).toEqual(123 + 456);
});
});
});

0 comments on commit 59eb2b6

Please sign in to comment.