Skip to content

Commit

Permalink
Merge c771b7b into 36e0b2e
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Henkel committed Feb 25, 2017
2 parents 36e0b2e + c771b7b commit f694d8d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/helpers/normalizeArgs.js
Expand Up @@ -16,7 +16,10 @@ function normalizeArgs(registry, args) {
return fn;
}

return map(flatten(args), getFunction);
var flattenArgs = flatten(args);
assert(flattenArgs.length, 'Arguments must be a non-empty array or string');

return map(flattenArgs, getFunction);
}

module.exports = normalizeArgs;
36 changes: 36 additions & 0 deletions test/series.js
Expand Up @@ -34,6 +34,42 @@ describe('series', function() {
done();
});

it('should throw on empty object on registered tasks array', function(done) {
function fail() {
taker.series(['test1', 'test2', 'test3', {}]);
}

expect(fail).toThrow(/Task never defined:/);
done();
});

it('should throw on empty object of registered task', function(done) {
function fail() {
taker.series({});
}

expect(fail).toThrow(/Task never defined:/);
done();
});

it('should throw on non registered tasks', function(done) {
function fail() {
taker.series();
}

expect(fail).toThrow(/Arguments must be a non-empty array or string/);
done();
});

it('should throw on empty array of registered tasks', function(done) {
function fail() {
taker.series([]);
}

expect(fail).toThrow(/Arguments must be a non-empty array or string/);
done();
});

it('should take only one array of registered tasks', function(done) {
taker.series(['test1', 'test2', 'test3'])(function(err, results) {
expect(results).toEqual([1, 2, 3]);
Expand Down

0 comments on commit f694d8d

Please sign in to comment.