Skip to content

Commit

Permalink
moar coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
aearly committed Jun 23, 2019
1 parent b5c3f2f commit c52c887
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/internal/setImmediate.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
'use strict';
/* istanbul ignore file */

export var hasSetImmediate = typeof setImmediate === 'function' && setImmediate;
export var hasNextTick = typeof process === 'object' && typeof process.nextTick === 'function';
Expand Down
11 changes: 11 additions & 0 deletions test/es2017/awaitableFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,17 @@ module.exports = function () {
expect(calls).to.eql([0, 1, 2])
});

it('should return a Promise: retry (multiple cb args)', async () => {
expect (async.retry.name).to.contain('retry')
let counter = 0
const results = await async.retry((cb) => {
counter++
if (counter < 3) return cb(new Error())
cb(null, 0, 1, 2)
})
expect(results).to.eql([0, 1, 2])
});

it('should return a Promise: tryEach', async () => {
expect (async.tryEach.name).to.contain('tryEach')
const calls = []
Expand Down
17 changes: 17 additions & 0 deletions test/retryable.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ describe('retryable', () => {
});
});

it('success', (done) => {
var calls = 0;
var retryableTask = async.retryable(3, (arg, cb) => {
calls++;
expect(arg).to.equal(42);
if (calls > 1) return cb (null, 1, 2)
cb('fail');
});

retryableTask(42, (err, a, b) => {
expect(err).to.eql(null);
expect(calls).to.equal(2);
expect([a, b]).to.eql([1, 2])
done();
});
});

it('basics with error test function', (done) => {
var calls = 0;
var special = 'special';
Expand Down

0 comments on commit c52c887

Please sign in to comment.