summaryrefslogtreecommitdiff
path: root/test/eachOf.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/eachOf.js')
-rw-r--r--test/eachOf.js154
1 files changed, 77 insertions, 77 deletions
diff --git a/test/eachOf.js b/test/eachOf.js
index 1701d3e..39c36cf 100644
--- a/test/eachOf.js
+++ b/test/eachOf.js
@@ -3,7 +3,7 @@ var expect = require('chai').expect;
var assert = require('assert');
var _ = require('lodash');
-describe("eachOf", function() {
+describe("eachOf", () => {
function forEachOfNoCallbackIteratee(done, x, key, callback) {
expect(x).to.equal(1);
@@ -13,37 +13,37 @@ describe("eachOf", function() {
}
function forEachOfIteratee(args, value, key, callback) {
- setTimeout(function(){
+ setTimeout(() => {
args.push(key, value);
callback();
}, value*25);
}
- it('eachOf alias', function(done) {
+ it('eachOf alias', (done) => {
expect(async.eachOf).to.equal(async.forEachOf);
done();
});
- it('eachOfLimit alias', function(done) {
+ it('eachOfLimit alias', (done) => {
expect(async.eachOfLimit).to.equal(async.forEachOfLimit);
done();
});
- it('eachOfSeries alias', function(done) {
+ it('eachOfSeries alias', (done) => {
expect(async.eachOfSeries).to.equal(async.forEachOfSeries);
done();
});
it('forEachOf', function(done) {
var args = [];
- async.forEachOf({ a: 1, b: 2 }, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOf({ a: 1, b: 2 }, forEachOfIteratee.bind(this, args), (err) => {
assert(err === null, err + " passed instead of 'null'");
expect(args).to.eql(["a", 1, "b", 2]);
done();
});
});
- it('forEachOf no call stack size exceed error', function(done) {
+ it('forEachOf no call stack size exceed error', (done) => {
var obj = {};
var len = 3000;
var args = new Array(len * 2);
@@ -55,56 +55,56 @@ describe("eachOf", function() {
expected[2 * i + 1] = i;
}
- async.forEachOf(obj, function(value, key, callback) {
+ async.forEachOf(obj, (value, key, callback) => {
var index = parseInt(key.slice(1), 10);
args[2 * index] = key;
args[2 * index + 1] = value;
callback();
- }, function(err) {
+ }, (err) => {
assert(err === null, err + " passed instead of 'null'");
expect(args).to.eql(expected);
done();
});
});
- it('forEachOf - instant resolver', function(done) {
+ it('forEachOf - instant resolver', (done) => {
var args = [];
- async.forEachOf({ a: 1, b: 2 }, function(x, k, cb) {
+ async.forEachOf({ a: 1, b: 2 }, (x, k, cb) => {
args.push(k, x);
cb();
- }, function(){
+ }, () => {
// ensures done callback isn't called before all items iterated
expect(args).to.eql(["a", 1, "b", 2]);
done();
});
});
- it('forEachOf empty object', function(done) {
- async.forEachOf({}, function(value, key, callback){
+ it('forEachOf empty object', (done) => {
+ async.forEachOf({}, (value, key, callback) => {
assert(false, 'iteratee should not be called');
callback();
- }, function(err) {
+ }, (err) => {
if (err) throw err;
assert(true, 'should call callback');
});
setTimeout(done, 25);
});
- it('forEachOf empty array', function(done) {
- async.forEachOf([], function(value, key, callback){
+ it('forEachOf empty array', (done) => {
+ async.forEachOf([], (value, key, callback) => {
assert(false, 'iteratee should not be called');
callback();
- }, function(err) {
+ }, (err) => {
if (err) throw err;
assert(true, 'should call callback');
});
setTimeout(done, 25);
});
- it('forEachOf error', function(done) {
- async.forEachOf({ a: 1, b: 2 }, function(value, key, callback) {
+ it('forEachOf error', (done) => {
+ async.forEachOf({ a: 1, b: 2 }, (value, key, callback) => {
callback('error');
- }, function(err){
+ }, (err) => {
expect(err).to.equal('error');
});
setTimeout(done, 50);
@@ -117,7 +117,7 @@ describe("eachOf", function() {
it('forEachOf with array', function(done) {
var args = [];
- async.forEachOf([ "a", "b" ], forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOf([ "a", "b" ], forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([0, "a", 1, "b"]);
done();
@@ -132,7 +132,7 @@ describe("eachOf", function() {
var set = new Set();
set.add("a");
set.add("b");
- async.forEachOf(set, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOf(set, forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([0, "a", 1, "b"]);
done();
@@ -147,7 +147,7 @@ describe("eachOf", function() {
var map = new Map();
map.set(1, "a");
map.set(2, "b");
- async.forEachOf(map, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOf(map, forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([0, [1, "a"], 1, [2, "b"]]);
done();
@@ -156,14 +156,14 @@ describe("eachOf", function() {
it('forEachOfSeries', function(done) {
var args = [];
- async.forEachOfSeries({ a: 1, b: 2 }, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOfSeries({ a: 1, b: 2 }, forEachOfIteratee.bind(this, args), (err) => {
assert(err === null, err + " passed instead of 'null'");
expect(args).to.eql([ "a", 1, "b", 2 ]);
done();
});
});
- it('forEachOfSeries no call stack size exceed error', function(done) {
+ it('forEachOfSeries no call stack size exceed error', (done) => {
var obj = {};
var len = 3000;
var args = new Array(len * 2);
@@ -175,35 +175,35 @@ describe("eachOf", function() {
expected[2 * i + 1] = i;
}
- async.forEachOfSeries(obj, function(value, key, callback) {
+ async.forEachOfSeries(obj, (value, key, callback) => {
var index = parseInt(key.slice(1), 10);
args[2 * index] = key;
args[2 * index + 1] = value;
callback();
- }, function(err) {
+ }, (err) => {
assert(err === null, err + " passed instead of 'null'");
expect(args).to.eql(expected);
done();
});
});
- it('forEachOfSeries empty object', function(done) {
- async.forEachOfSeries({}, function(x, callback){
+ it('forEachOfSeries empty object', (done) => {
+ async.forEachOfSeries({}, (x, callback) => {
assert(false, 'iteratee should not be called');
callback();
- }, function(err){
+ }, (err) => {
if (err) throw err;
assert(true, 'should call callback');
});
setTimeout(done, 25);
});
- it('forEachOfSeries error', function(done) {
+ it('forEachOfSeries error', (done) => {
var call_order = [];
- async.forEachOfSeries({ a: 1, b: 2 }, function(value, key, callback){
+ async.forEachOfSeries({ a: 1, b: 2 }, (value, key, callback) => {
call_order.push(value, key);
callback('error');
- }, function(err){
+ }, (err) => {
expect(call_order).to.eql([ 1, "a" ]);
expect(err).to.equal('error');
});
@@ -216,7 +216,7 @@ describe("eachOf", function() {
it('forEachOfSeries with array', function(done) {
var args = [];
- async.forEachOfSeries([ "a", "b" ], forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOfSeries([ "a", "b" ], forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([ 0, "a", 1, "b" ]);
done();
@@ -231,7 +231,7 @@ describe("eachOf", function() {
var set = new Set();
set.add("a");
set.add("b");
- async.forEachOfSeries(set, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOfSeries(set, forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([0, "a", 1, "b"]);
done();
@@ -246,33 +246,33 @@ describe("eachOf", function() {
var map = new Map();
map.set(1, "a");
map.set(2, "b");
- async.forEachOfSeries(map, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOfSeries(map, forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([0, [1, "a"], 1, [2, "b"]]);
done();
});
});
- it('forEachOfLimit', function(done) {
+ it('forEachOfLimit', (done) => {
var args = [];
var obj = { a: 1, b: 2, c: 3, d: 4 };
- async.forEachOfLimit(obj, 2, function(value, key, callback){
- setTimeout(function(){
+ async.forEachOfLimit(obj, 2, (value, key, callback) => {
+ setTimeout(() => {
args.push(value, key);
callback();
}, value * 5);
- }, function(err){
+ }, (err) => {
assert(err === null, err + " passed instead of 'null'");
expect(args).to.eql([ 1, "a", 2, "b", 3, "c", 4, "d" ]);
done();
});
});
- it('forEachOfLimit empty object', function(done) {
- async.forEachOfLimit({}, 2, function(value, key, callback){
+ it('forEachOfLimit empty object', (done) => {
+ async.forEachOfLimit({}, 2, (value, key, callback) => {
assert(false, 'iteratee should not be called');
callback();
- }, function(err){
+ }, (err) => {
if (err) throw err;
assert(true, 'should call callback');
});
@@ -282,7 +282,7 @@ describe("eachOf", function() {
it('forEachOfLimit limit exceeds size', function(done) {
var args = [];
var obj = { a: 1, b: 2, c: 3, d: 4, e: 5 };
- async.forEachOfLimit(obj, 10, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOfLimit(obj, 10, forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([ "a", 1, "b", 2, "c", 3, "d", 4, "e", 5 ]);
done();
@@ -292,58 +292,58 @@ describe("eachOf", function() {
it('forEachOfLimit limit equal size', function(done) {
var args = [];
var obj = { a: 1, b: 2, c: 3, d: 4, e: 5 };
- async.forEachOfLimit(obj, 5, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOfLimit(obj, 5, forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([ "a", 1, "b", 2, "c", 3, "d", 4, "e", 5 ]);
done();
});
});
- it('forEachOfLimit zero limit', function() {
+ it('forEachOfLimit zero limit', () => {
expect(() => {
- async.forEachOfLimit({ a: 1, b: 2 }, 0, function(x, callback){
+ async.forEachOfLimit({ a: 1, b: 2 }, 0, (x, callback) => {
assert(false, 'iteratee should not be called');
callback();
- }, function(){
+ }, () => {
assert(true, 'should call callback');
});
}).to.throw(/concurrency limit/)
});
- it('forEachOfLimit no limit', function(done) {
+ it('forEachOfLimit no limit', (done) => {
var count = 0;
- async.forEachOfLimit(_.range(100), Infinity, function(x, i, callback){
+ async.forEachOfLimit(_.range(100), Infinity, (x, i, callback) => {
count++;
callback();
- }, function(err){
+ }, (err) => {
if (err) throw err;
expect(count).to.equal(100);
});
setTimeout(done, 25);
});
- it('forEachOfLimit no call stack size exceed error', function(done) {
+ it('forEachOfLimit no call stack size exceed error', (done) => {
var count = 0;
- async.forEachOfLimit(_.range(1024 * 1024), Infinity, function(x, i, callback){
+ async.forEachOfLimit(_.range(1024 * 1024), Infinity, (x, i, callback) => {
count++;
callback();
- }, function(err){
+ }, (err) => {
if (err) throw err;
expect(count).to.equal(1024 * 1024);
done();
});
});
- it('forEachOfLimit error', function(done) {
+ it('forEachOfLimit error', (done) => {
var obj = { a: 1, b: 2, c: 3, d: 4, e: 5 };
var call_order = [];
- async.forEachOfLimit(obj, 3, function(value, key, callback){
+ async.forEachOfLimit(obj, 3, (value, key, callback) => {
call_order.push(value, key);
if (value === 2) {
callback('error');
}
- }, function(err){
+ }, (err) => {
expect(call_order).to.eql([ 1, "a", 2, "b" ]);
expect(err).to.equal('error');
});
@@ -357,7 +357,7 @@ describe("eachOf", function() {
it('forEachOfLimit synchronous', function(done) {
var args = [];
var obj = { a: 1, b: 2 };
- async.forEachOfLimit(obj, 5, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOfLimit(obj, 5, forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([ "a", 1, "b", 2 ]);
done();
@@ -367,7 +367,7 @@ describe("eachOf", function() {
it('forEachOfLimit with array', function(done) {
var args = [];
var arr = [ "a", "b" ];
- async.forEachOfLimit(arr, 1, forEachOfIteratee.bind(this, args), function (err) {
+ async.forEachOfLimit(arr, 1, forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([ 0, "a", 1, "b" ]);
done();
@@ -382,7 +382,7 @@ describe("eachOf", function() {
var set = new Set();
set.add("a");
set.add("b");
- async.forEachOfLimit(set, 1, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOfLimit(set, 1, forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([0, "a", 1, "b"]);
done();
@@ -397,24 +397,24 @@ describe("eachOf", function() {
var map = new Map();
map.set(1, "a");
map.set(2, "b");
- async.forEachOfLimit(map, 1, forEachOfIteratee.bind(this, args), function(err){
+ async.forEachOfLimit(map, 1, forEachOfIteratee.bind(this, args), (err) => {
if (err) throw err;
expect(args).to.eql([0, [1, "a"], 1, [2, "b"]]);
done();
});
});
- it('forEachOfLimit canceled', function(done) {
+ it('forEachOfLimit canceled', (done) => {
var obj = { a: 1, b: 2, c: 3, d: 4, e: 5 };
var call_order = [];
- async.forEachOfLimit(obj, 3, function(value, key, callback){
+ async.forEachOfLimit(obj, 3, (value, key, callback) => {
call_order.push(value, key);
if (value === 2) {
return callback(false);
}
callback()
- }, function(){
+ }, () => {
throw new Error('should not get here')
});
setTimeout(() => {
@@ -423,11 +423,11 @@ describe("eachOf", function() {
}, 10);
});
- it('forEachOfLimit canceled (async)', function(done) {
+ it('forEachOfLimit canceled (async)', (done) => {
var obj = { a: 1, b: 2, c: 3, d: 4, e: 5 };
var call_order = [];
- async.forEachOfLimit(obj, 3, function(value, key, callback){
+ async.forEachOfLimit(obj, 3, (value, key, callback) => {
call_order.push(value, key);
setTimeout(() => {
if (value === 2) {
@@ -435,7 +435,7 @@ describe("eachOf", function() {
}
callback()
})
- }, function(){
+ }, () => {
throw new Error('should not get here')
});
setTimeout(() => {
@@ -444,11 +444,11 @@ describe("eachOf", function() {
}, 20);
});
- it('eachOfLimit canceled (async, array)', function(done) {
+ it('eachOfLimit canceled (async, array)', (done) => {
var obj = ['a', 'b', 'c', 'd', 'e'];
var call_order = [];
- async.eachOfLimit(obj, 3, function(value, key, callback){
+ async.eachOfLimit(obj, 3, (value, key, callback) => {
call_order.push(key, value);
setTimeout(() => {
if (value === 'b') {
@@ -456,7 +456,7 @@ describe("eachOf", function() {
}
callback()
})
- }, function(){
+ }, () => {
throw new Error('should not get here')
});
setTimeout(() => {
@@ -465,11 +465,11 @@ describe("eachOf", function() {
}, 20);
});
- it('eachOf canceled (async, array)', function(done) {
+ it('eachOf canceled (async, array)', (done) => {
var arr = ['a', 'b', 'c', 'd', 'e'];
var call_order = [];
- async.eachOf(arr, function(value, key, callback){
+ async.eachOf(arr, (value, key, callback) => {
call_order.push(key, value);
setTimeout(() => {
if (value === 'b') {
@@ -477,7 +477,7 @@ describe("eachOf", function() {
}
callback()
})
- }, function(){
+ }, () => {
throw new Error('should not get here')
});
setTimeout(() => {
@@ -486,11 +486,11 @@ describe("eachOf", function() {
}, 20);
});
- it('forEachOfLimit canceled (async, w/ error)', function(done) {
+ it('forEachOfLimit canceled (async, w/ error)', (done) => {
var obj = { a: 1, b: 2, c: 3, d: 4, e: 5 };
var call_order = [];
- async.forEachOfLimit(obj, 3, function(value, key, callback){
+ async.forEachOfLimit(obj, 3, (value, key, callback) => {
call_order.push(value, key);
setTimeout(() => {
if (value === 2) {
@@ -501,7 +501,7 @@ describe("eachOf", function() {
}
callback()
})
- }, function(){
+ }, () => {
throw new Error('should not get here')
});
setTimeout(() => {