Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export default function auto(tasks, concurrency, callback) {
callback = once(callback || promiseCallback());
var numTasks = Object.keys(tasks).length;
if (!numTasks) {
return callback(null);
callback(null);
return callback[PROMISE_SYMBOL];
}
if (!concurrency) {
concurrency = numTasks;
Expand Down
15 changes: 15 additions & 0 deletions test/es2017/awaitableFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,16 @@ module.exports = function () {
});
expect(calls).to.eql(['a', 'c', 'b'])
});
it('should return a Promise: auto with no tasks', () => {
return async.auto({}).then(result => {
expect(result).to.equal(undefined)
})
});
it('should return a Promise: auto with no tasks and a concurrency limit', () => {
return async.auto({}, 2).then(result => {
expect(result).to.equal(undefined)
})
});
it('should return a Promise: autoInject', async () => {
const calls = []
await async.autoInject({
Expand All @@ -323,6 +333,11 @@ module.exports = function () {
}, 1);
expect(calls).to.eql(['a', 'c', 'b', 'a', 'c'])
});
it('should return a Promise: autoInject with no tasks', () => {
return async.autoInject({}).then(result => {
expect(result).to.equal(undefined)
})
});

it('should return a Promise: compose', async () => {
const calls = []
Expand Down