diff options
Diffstat (limited to 'test/priorityQueue.js')
-rw-r--r-- | test/priorityQueue.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/test/priorityQueue.js b/test/priorityQueue.js index 2d9d4a5..e1c3b29 100644 --- a/test/priorityQueue.js +++ b/test/priorityQueue.js @@ -239,5 +239,41 @@ describe('priorityQueue', () => { q.push('foo4', 1, () => {calls.push('foo4 cb');}); }); }); + + it('should not call the drain callback if receives empty push and tasks are still pending', (done) => { + var call_order = []; + + var q = async.priorityQueue((task, callback) => { + call_order.push('process ' + task); + callback('error', 'arg'); + }, 1); + + q.push(1, 1, (err, arg) => { + expect(err).to.equal('error'); + expect(arg).to.equal('arg'); + call_order.push('callback ' + 1); + }); + + q.push(2, 1, (err, arg) => { + expect(err).to.equal('error'); + expect(arg).to.equal('arg'); + call_order.push('callback ' + 2); + }); + + expect(q.length()).to.equal(2); + + q.drain = function () { + expect(call_order).to.eql([ + 'process 1', 'callback 1', + 'process 2', 'callback 2' + ]); + expect(q.concurrency).to.equal(1); + expect(q.length()).to.equal(0); + expect(q.running()).to.equal(0); + done(); + }; + + q.push([], 1, () => {}); + }); }); |