diff options
author | Caolan McMahon <caolan.mcmahon@gmail.com> | 2014-03-28 12:41:10 +0000 |
---|---|---|
committer | Caolan McMahon <caolan.mcmahon@gmail.com> | 2014-03-28 12:41:10 +0000 |
commit | 191a5076bf4a9cb6ac87b1bf6e9d4eb0a13527d7 (patch) | |
tree | 5fb93d2e26634692c513ca9dd884b3a6d3c43b2f /test | |
parent | 287cb65116c34f5fff1b953c6b9a95bce0a3dbde (diff) | |
parent | c2b098bb46c9c17bb901a91073dae461dfad7ca8 (diff) | |
download | async-191a5076bf4a9cb6ac87b1bf6e9d4eb0a13527d7.tar.gz |
Merge pull request #433 from tikonen/master
Queue calls drain if empty task list is pushed
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-async.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/test/test-async.js b/test/test-async.js index fd6fe46..d18262a 100755 --- a/test/test-async.js +++ b/test/test-async.js @@ -2483,3 +2483,25 @@ exports['queue events'] = function(test) { q.push('poo', function () {calls.push('poo cb');}); q.push('moo', function () {calls.push('moo cb');}); }; + +exports['queue empty'] = function(test) { + var calls = []; + var q = async.queue(function(task, cb) { + // nop + calls.push('process ' + task); + async.setImmediate(cb); + }, 3); + + q.drain = function() { + test.ok( + q.length() == 0 && q.running() == 0, + 'queue should be empty now and no more workers should be running' + ); + calls.push('drain'); + test.same(calls, [ + 'drain' + ]); + test.done(); + }; + q.push([]); +}; |