summaryrefslogtreecommitdiff
path: root/test/series.js
diff options
context:
space:
mode:
authorAlex Early <alexander.early@gmail.com>2018-07-08 16:58:36 -0700
committerGitHub <noreply@github.com>2018-07-08 16:58:36 -0700
commite4751178540a3c6e64598b93977481ec599704d2 (patch)
treedce5731bdb1076971d2e4a0a42fbe0d95c720185 /test/series.js
parent6405b109fe60541ff42d7638ac891d321d6a7bb3 (diff)
downloadasync-e4751178540a3c6e64598b93977481ec599704d2.tar.gz
ES6-ify codebase (#1553)
* cancelable foreach * cancelable waterfall * cancellable auto * fix lint * fix tests * cancelable whilst/until/during/forever * fix waterfall test. It WILL get there * docs * use rest params instead of slice * clean up internals * remove property func * clarify uses of createTester * happy path async funtions in asyncify * stop using arguments * DLL to class * moar arrows * fix merge issues * remove forOwn * moar arrows * fix merge mistake * even more arrows, what can stop him * mo more fn.apply(null,...) * remove more spurious uses of apply * update lint config * just when you thought there couldn't possibly be more arrows * use eslint:recommended * even less uses or aguments * get rid of prototype cuteness * fix concat tests * fix more tests
Diffstat (limited to 'test/series.js')
-rw-r--r--test/series.js72
1 files changed, 36 insertions, 36 deletions
diff --git a/test/series.js b/test/series.js
index 7d737fa..8ee5374 100644
--- a/test/series.js
+++ b/test/series.js
@@ -3,30 +3,30 @@ var expect = require('chai').expect;
var assert = require('assert');
var getFunctionsObject = require('./support/get_function_object');
-describe('series', function() {
- it('series', function(done) {
+describe('series', () => {
+ it('series', (done) => {
var call_order = [];
async.series([
function(callback){
- setTimeout(function(){
+ setTimeout(() => {
call_order.push(1);
callback(null, 1);
}, 25);
},
function(callback){
- setTimeout(function(){
+ setTimeout(() => {
call_order.push(2);
callback(null, 2);
}, 50);
},
function(callback){
- setTimeout(function(){
+ setTimeout(() => {
call_order.push(3);
callback(null, 3,3);
}, 15);
}
],
- function(err, results){
+ (err, results) => {
assert(err === null, err + " passed instead of 'null'");
expect(results).to.eql([1,2,[3,3]]);
expect(call_order).to.eql([1,2,3]);
@@ -34,29 +34,29 @@ describe('series', function() {
});
});
- it('with reflect', function(done) {
+ it('with reflect', (done) => {
var call_order = [];
async.series([
- async.reflect(function(callback){
- setTimeout(function(){
+ async.reflect((callback) => {
+ setTimeout(() => {
call_order.push(1);
callback(null, 1);
}, 25);
}),
- async.reflect(function(callback){
- setTimeout(function(){
+ async.reflect((callback) => {
+ setTimeout(() => {
call_order.push(2);
callback(null, 2);
}, 50);
}),
- async.reflect(function(callback){
- setTimeout(function(){
+ async.reflect((callback) => {
+ setTimeout(() => {
call_order.push(3);
callback(null, 3,3);
}, 15);
})
],
- function(err, results){
+ (err, results) => {
assert(err === null, err + " passed instead of 'null'");
expect(results).to.eql([
{ value: 1 },
@@ -68,15 +68,15 @@ describe('series', function() {
});
});
- it('empty array', function(done) {
- async.series([], function(err, results){
+ it('empty array', (done) => {
+ async.series([], (err, results) => {
expect(err).to.equal(null);
expect(results).to.eql([]);
done();
});
});
- it('error', function(done) {
+ it('error', (done) => {
async.series([
function(callback){
callback('error', 1);
@@ -86,25 +86,25 @@ describe('series', function() {
callback('error2', 2);
}
],
- function(err){
+ (err) => {
expect(err).to.equal('error');
});
setTimeout(done, 100);
});
- it('error with reflect', function(done) {
+ it('error with reflect', (done) => {
async.series([
- async.reflect(function(callback){
+ async.reflect((callback) => {
callback('error', 1);
}),
- async.reflect(function(callback){
+ async.reflect((callback) => {
callback('error2', 2);
}),
- async.reflect(function(callback){
+ async.reflect((callback) => {
callback(null, 1);
})
],
- function(err, results){
+ (err, results) => {
assert(err === null, err + " passed instead of 'null'");
expect(results).to.eql([
{ error: 'error' },
@@ -115,16 +115,16 @@ describe('series', function() {
});
});
- it('no callback', function(done) {
+ it('no callback', (done) => {
async.series([
function(callback){callback();},
function(callback){callback(); done();},
]);
});
- it('object', function(done) {
+ it('object', (done) => {
var call_order = [];
- async.series(getFunctionsObject(call_order), function(err, results){
+ async.series(getFunctionsObject(call_order), (err, results) => {
expect(err).to.equal(null);
expect(results).to.eql({
one: 1,
@@ -136,17 +136,17 @@ describe('series', function() {
});
});
- it('call in another context @nycinvalid @nodeonly', function(done) {
+ it('call in another context @nycinvalid @nodeonly', (done) => {
var vm = require('vm');
var sandbox = {
- async: async,
- done: done
+ async,
+ done
};
var fn = "(" + (function () {
async.series([function (callback) {
callback();
- }], function (err) {
+ }], (err) => {
if (err) {
return done(err);
}
@@ -158,30 +158,30 @@ describe('series', function() {
});
// Issue 10 on github: https://github.com/caolan/async/issues#issue/10
- it('falsy return values', function(done) {
+ it('falsy return values', (done) => {
function taskFalse(callback) {
- async.nextTick(function() {
+ async.nextTick(() => {
callback(null, false);
});
}
function taskUndefined(callback) {
- async.nextTick(function() {
+ async.nextTick(() => {
callback(null, undefined);
});
}
function taskEmpty(callback) {
- async.nextTick(function() {
+ async.nextTick(() => {
callback(null);
});
}
function taskNull(callback) {
- async.nextTick(function() {
+ async.nextTick(() => {
callback(null, null);
});
}
async.series(
[taskFalse, taskUndefined, taskEmpty, taskNull],
- function(err, results) {
+ (err, results) => {
expect(results.length).to.equal(4);
assert.strictEqual(results[0], false);
assert.strictEqual(results[1], undefined);