summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/priorityQueue.js1
-rw-r--r--mocha_test/parallel.js2
-rw-r--r--mocha_test/priorityQueue.js29
-rw-r--r--mocha_test/series.js2
-rw-r--r--mocha_test/waterfall.js2
-rw-r--r--package.json4
6 files changed, 35 insertions, 5 deletions
diff --git a/lib/priorityQueue.js b/lib/priorityQueue.js
index 147a009..d8b6016 100644
--- a/lib/priorityQueue.js
+++ b/lib/priorityQueue.js
@@ -51,6 +51,7 @@ export default function(worker, concurrency) {
});
}
+ priority = priority || 0;
var nextNode = q._tasks.head;
while (nextNode && priority >= nextNode.priority) {
nextNode = nextNode.next;
diff --git a/mocha_test/parallel.js b/mocha_test/parallel.js
index bad98af..4f92642 100644
--- a/mocha_test/parallel.js
+++ b/mocha_test/parallel.js
@@ -192,7 +192,7 @@ describe('parallel', function() {
});
});
- it('parallel call in another context', function(done) {
+ it('parallel call in another context @nycinvalid', function(done) {
if (isBrowser()) {
// node only test
done();
diff --git a/mocha_test/priorityQueue.js b/mocha_test/priorityQueue.js
index b777815..f71e665 100644
--- a/mocha_test/priorityQueue.js
+++ b/mocha_test/priorityQueue.js
@@ -108,6 +108,35 @@ describe('priorityQueue', function() {
};
});
+ it('pause in worker with concurrency', function(done) {
+ var call_order = [];
+ var q = async.priorityQueue(function (task, callback) {
+ if (task.isLongRunning) {
+ q.pause();
+ setTimeout(function () {
+ call_order.push(task.id);
+ q.resume();
+ callback();
+ }, 50);
+ }
+ else {
+ call_order.push(task.id);
+ setTimeout(callback, 10);
+ }
+ }, 10);
+
+ q.push({ id: 1, isLongRunning: true});
+ q.push({ id: 2 });
+ q.push({ id: 3 });
+ q.push({ id: 4 });
+ q.push({ id: 5 });
+
+ q.drain = function () {
+ expect(call_order).to.eql([1, 2, 3, 4, 5]);
+ done();
+ };
+ });
+
context('q.saturated(): ', function() {
it('should call the saturated callback if tasks length is concurrency', function(done) {
var calls = [];
diff --git a/mocha_test/series.js b/mocha_test/series.js
index 0237582..80e54c2 100644
--- a/mocha_test/series.js
+++ b/mocha_test/series.js
@@ -137,7 +137,7 @@ describe('series', function() {
});
});
- it('call in another context', function(done) {
+ it('call in another context @nycinvalid', function(done) {
if (isBrowser()) {
// node only test
done();
diff --git a/mocha_test/waterfall.js b/mocha_test/waterfall.js
index 7053b2c..c9abdc9 100644
--- a/mocha_test/waterfall.js
+++ b/mocha_test/waterfall.js
@@ -106,7 +106,7 @@ describe("waterfall", function () {
}).to.throw(/already called/);
});
- it('call in another context', function(done) {
+ it('call in another context @nycinvalid', function(done) {
if (process.browser) {
// node only test
done();
diff --git a/package.json b/package.json
index 2590d97..a4879ef 100644
--- a/package.json
+++ b/package.json
@@ -59,8 +59,8 @@
"yargs": "~3.9.1"
},
"scripts": {
- "coverage": "nyc npm run mocha-node-test && nyc report",
- "coveralls": "npm run mocha-node-test && nyc report --reporter=text-lcov | coveralls",
+ "coverage": "nyc npm run mocha-node-test -- --grep @nycinvalid --invert",
+ "coveralls": "npm run coverage && nyc report --reporter=text-lcov | coveralls",
"jsdoc": "jsdoc -c ./support/jsdoc/jsdoc.json && node support/jsdoc/jsdoc-fix-html.js",
"lint": "eslint lib/ mocha_test/ perf/memory.js perf/suites.js perf/benchmark.js support/build/ support/*.js karma.conf.js",
"mocha-browser-test": "karma start",