Skip to content

Commit

Permalink
Merge 4c2bd02 into ce0a7e2
Browse files Browse the repository at this point in the history
  • Loading branch information
hargasinski committed Feb 28, 2019
2 parents ce0a7e2 + 4c2bd02 commit f3554ae
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/whilst.js
Expand Up @@ -40,7 +40,7 @@ function whilst(test, iteratee, callback) {
callback = onlyOnce(callback);
var _fn = wrapAsync(iteratee);
var _test = wrapAsync(test);
var results
var results = [];

function next(err, ...rest) {
if (err) return callback(err);
Expand Down
18 changes: 18 additions & 0 deletions test/whilst.js
Expand Up @@ -64,6 +64,24 @@ describe('whilst', () => {
}, 10)
});

it('should not error when test is false on first iteration', (done) => {
var counter = 0;

async.whilst(
(cb) => cb(null, false),
(cb) => {
counter++;
cb(null);
},
(err, result) => {
expect(err).to.eql(null);
expect(result).to.be.undefined;
expect(counter).to.equal(0);
done();
}
);
});

it('doWhilst', (done) => {
var call_order = [];

Expand Down

0 comments on commit f3554ae

Please sign in to comment.