Permalink
Browse files

test: [drain] emit drain in nexttick

  • Loading branch information...
1 parent 6cd891c commit 0c5b171318d09add7c23d0c52c0097704f2b0a09 @logicalparadox logicalparadox committed Feb 15, 2013
Showing with 23 additions and 0 deletions.
  1. +23 −0 test/queue.js
View
@@ -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.