Skip to content

Commit

Permalink
test(each): add generator test
Browse files Browse the repository at this point in the history
  • Loading branch information
suguru03 committed May 13, 2019
1 parent a111632 commit 6a20cee
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/collections/test.each.js
Original file line number Diff line number Diff line change
Expand Up @@ -1363,4 +1363,27 @@ parallel('#eachLimit', function() {
});
});

it('should work with generator', function(done) {
var limit = 2;
var collection = ['abc', 'def', 'ghi', 'jkl'];
var order = [];
var gen = util.makeGenerator(collection);

async.eachLimit(
gen,
limit,
function(v, i, cb) {
order.push(i);
setTimeout(cb, Math.random() * delay, null, v);
},
function(err) {
if (err) {
return done();
}
assert.deepStrictEqual(order, [0, 1, 2, 3]);
done();
}
);
});

});

0 comments on commit 6a20cee

Please sign in to comment.