Skip to content

Commit

Permalink
Tests for .spread reject handler in bluebird v2
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Sep 3, 2016
1 parent f1cf43c commit 36b7132
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
18 changes: 14 additions & 4 deletions test/methods/core/spread.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@
* Tests for .spread()
*/

/* global describe */

// Imports
var runTests = require('../../support');

// Run tests

// TODO Add tests for reject handler in bluebird v2
// TODO Add tests for when both handlers provided
runTests('.spread()', function(u) {
u.testGroupProtoAsyncArrayHandler(function(p, handler) {
return p.spread(handler);
}, {noUndefinedValue: true, noUndefinedHandler: true, oneCallback: true});
describe('resolve handler', function() {
u.testGroupProtoAsyncArrayHandler(function(p, handler) {
return p.spread(handler);
}, {noUndefinedValue: true, noUndefinedHandler: true, oneCallback: true});
});

(u.bluebirdVersion === 2 ? describe : describe.skip)('reject handler', function() {
u.testGroupProtoAsyncArrayHandler(function(p, handler) {
return p.spread(undefined, handler);
}, {catches: true, noUndefinedValue: true, noUndefinedHandler: true, oneCallback: true});
});
});
11 changes: 7 additions & 4 deletions test/support/utils/testSets/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ module.exports = {
*
* @param {Function} fn - Test function
* @param {Object} [options] - Options object
* @param {boolean} [options.continues] - true if handler fires on resolved promise (default `!options.catches`)
* @param {boolean} [options.catches] - true if handler fires on rejected promise (default `false`)
* @param {boolean} [options.noUndefinedValue=false] - true if method does not accept undefined value
* @param {boolean} [options.noUndefinedHandler=false] - true if method does not accept undefined handler
* @param {boolean} [options.series=false] - true if method iterates through array in series
Expand All @@ -164,17 +166,18 @@ module.exports = {
var u = this;

// Conform options
options = _.defaults({
continues: true,
options = _.extend({
catches: false,
passThrough: false
}, options, {
noUndefinedValue: false,
noUndefinedHandler: false,
series: false,
oneCallback: false
}, options, {
passThrough: false
});

_.defaults(options, {continues: !options.catches});

// Run tests
u.testSetReturnsPromiseProtoOnArrayReceivingHandler(fn, options);
u.testSetCallbackAsyncProtoArray(fn, options);
Expand Down

0 comments on commit 36b7132

Please sign in to comment.