summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraeme Yeates <yeatesgraeme@gmail.com>2016-02-24 10:43:42 -0500
committerGraeme Yeates <yeatesgraeme@gmail.com>2016-02-24 10:43:42 -0500
commit29c302e53a3e61f6ca39742082d63a2679be2eb6 (patch)
tree48ed8d7eae77f53d4ca2c0fd898ab05c898b3b99
parent3d1781cbb9a215b30fc03c2135309fe3579e5689 (diff)
parent0ab9c9bf40ae573e7793a87600169d90ae8e79a1 (diff)
downloadasync-29c302e53a3e61f6ca39742082d63a2679be2eb6.tar.gz
Merge pull request #1033 from suguru03/fix-queue-test
fix queue test
-rw-r--r--mocha_test/queue.js24
1 files changed, 22 insertions, 2 deletions
diff --git a/mocha_test/queue.js b/mocha_test/queue.js
index fab423a..f64eef5 100644
--- a/mocha_test/queue.js
+++ b/mocha_test/queue.js
@@ -5,6 +5,7 @@ var expect = require('chai').expect;
describe('queue', function(){
context('q.unsaturated(): ',function() {
it('should have a default buffer property that equals 25% of the concurrenct rate', function(done){
+ var calls = [];
var q = async.queue(function(task, cb) {
// nop
calls.push('process ' + task);
@@ -14,6 +15,7 @@ describe('queue', function(){
done();
});
it('should allow a user to change the buffer property', function(done){
+ var calls = [];
var q = async.queue(function(task, cb) {
// nop
calls.push('process ' + task);
@@ -27,7 +29,6 @@ describe('queue', function(){
it('should call the unsaturated callback if tasks length is less than concurrency minus buffer', function(done){
var calls = [];
var q = async.queue(function(task, cb) {
- // nop
calls.push('process ' + task);
async.setImmediate(cb);
}, 10);
@@ -36,7 +37,26 @@ describe('queue', function(){
};
q.empty = function() {
expect(calls.indexOf('unsaturated')).to.be.above(-1);
- done();
+ setTimeout(function() {
+ expect(calls).eql([
+ 'unsaturated',
+ 'unsaturated',
+ 'unsaturated',
+ 'unsaturated',
+ 'unsaturated',
+ 'process foo0',
+ 'process foo1',
+ 'process foo2',
+ 'process foo3',
+ 'process foo4',
+ 'foo0 cb',
+ 'foo1 cb',
+ 'foo2 cb',
+ 'foo3 cb',
+ 'foo4 cb'
+ ]);
+ done();
+ }, 50);
};
q.push('foo0', function () {calls.push('foo0 cb');});
q.push('foo1', function () {calls.push('foo1 cb');});