Skip to content

Commit

Permalink
test: [drain] emit drain in nexttick
Browse files Browse the repository at this point in the history
  • Loading branch information
logicalparadox committed Feb 15, 2013
1 parent 6cd891c commit 0c5b171
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,27 @@ describe('queue', function () {
done();
}, 100);
});

it('should emit drain immediately if paused when no workers', function (done) {
var iterator = chai.spy('iterator', function (req, next) {
setTimeout(function () {
next(null);
}, 10);
});

var drainSpy = chai.spy('drain');

var q = new Queue(iterator, 2);
q.drain = drainSpy;

setTimeout(function () {
q.pause();
}, 10);

setTimeout(function () {
iterator.should.not.have.been.called;
drainSpy.should.have.been.called.once;
done();
}, 100);
});
});

0 comments on commit 0c5b171

Please sign in to comment.