diff --git a/lib/auto.js b/lib/auto.js index 82251ebd9..cbf131e3e 100644 --- a/lib/auto.js +++ b/lib/auto.js @@ -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; diff --git a/test/es2017/awaitableFunctions.js b/test/es2017/awaitableFunctions.js index d68a18f3a..6677252a3 100644 --- a/test/es2017/awaitableFunctions.js +++ b/test/es2017/awaitableFunctions.js @@ -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({ @@ -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 = []