summaryrefslogtreecommitdiff
path: root/test/es2017/awaitableFunctions.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/es2017/awaitableFunctions.js')
-rw-r--r--test/es2017/awaitableFunctions.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/es2017/awaitableFunctions.js b/test/es2017/awaitableFunctions.js
index fc866fa..6b375c3 100644
--- a/test/es2017/awaitableFunctions.js
+++ b/test/es2017/awaitableFunctions.js
@@ -29,6 +29,14 @@ module.exports = function () {
});
it('should throw as expected (callback)', async () => {
+ let thrown
+ await async.each(input, (val) => {
+ throw new Error(val)
+ }).catch(e => {thrown = e})
+ expect(thrown).to.be.an('error')
+ })
+
+ it('should throw as expected (callback, try/catch)', async () => {
try {
await async.each(input, (val, cb) => { cb(new Error(val)) });
} catch (e) {
@@ -42,33 +50,39 @@ module.exports = function () {
*/
it('should return a Promise: each', async () => {
+ expect (async.each.name).to.contain('each')
const calls = []
await async.each(input, async val => { calls.push(val) });
expect(calls).to.eql([1, 2, 3])
expect(async.each(input, asyncIdentity) instanceof Promise).to.equal(true)
});
it('should return a Promise: eachSeries', async () => {
+ expect (async.eachSeries.name).to.contain('eachSeries')
const calls = []
await async.eachSeries(input, async val => { calls.push(val) });
expect(calls).to.eql([1, 2, 3])
});
it('should return a Promise: eachLimit', async () => {
+ expect (async.eachLimit.name).to.contain('eachLimit')
const calls = []
await async.eachLimit(input, 1, async val => { calls.push(val) });
expect(calls).to.eql([1, 2, 3])
});
it('should return a Promise: eachOf', async () => {
+ expect (async.eachOf.name).to.contain('eachOf')
const calls = []
await async.eachOf(inputObj, async (...args) => { calls.push(args) });
expect(calls).to.eql([[1, 'a'], [2, 'b'], [3, 'c']])
});
it('should return a Promise: eachOfSeries', async () => {
+ expect (async.eachOfSeries.name).to.contain('eachOfSeries')
const calls = []
await async.eachOfSeries(inputObj, async (...args) => { calls.push(args) });
expect(calls).to.eql([[1, 'a'], [2, 'b'], [3, 'c']])
});
it('should return a Promise: eachOfLimit', async () => {
+ expect (async.eachOfLimit.name).to.contain('eachOfLimit')
const calls = []
await async.eachOfLimit(inputObj, 1, async (...args) => { calls.push(args) });
expect(calls).to.eql([[1, 'a'], [2, 'b'], [3, 'c']])