diff options
Diffstat (limited to 'test/times.js')
-rw-r--r-- | test/times.js | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/test/times.js b/test/times.js index ad1dfcd..ac7d49c 100644 --- a/test/times.js +++ b/test/times.js @@ -2,86 +2,86 @@ var async = require('../lib'); var expect = require('chai').expect; var assert = require('assert'); -describe('times', function() { +describe('times', () => { - it('times', function(done) { - async.times(5, function(n, next) { + it('times', (done) => { + async.times(5, (n, next) => { next(null, n); - }, function(err, results) { + }, (err, results) => { assert(err === null, err + " passed instead of 'null'"); expect(results).to.eql([0,1,2,3,4]); done(); }); }); - it('times 3', function(done) { + it('times 3', (done) => { var args = []; - async.times(3, function(n, callback){ - setTimeout(function(){ + async.times(3, (n, callback) => { + setTimeout(() => { args.push(n); callback(); }, n * 25); - }, function(err){ + }, (err) => { if (err) throw err; expect(args).to.eql([0,1,2]); done(); }); }); - it('times 0', function(done) { - async.times(0, function(n, callback){ + it('times 0', (done) => { + async.times(0, (n, 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('times error', function(done) { - async.times(3, function(n, callback){ + it('times error', (done) => { + async.times(3, (n, callback) => { callback('error'); - }, function(err){ + }, (err) => { expect(err).to.equal('error'); }); setTimeout(done, 50); }); - it('timesSeries', function(done) { + it('timesSeries', (done) => { var call_order = []; - async.timesSeries(5, function(n, callback){ - setTimeout(function(){ + async.timesSeries(5, (n, callback) => { + setTimeout(() => { call_order.push(n); callback(null, n); }, 100 - n * 10); - }, function(err, results){ + }, (err, results) => { expect(call_order).to.eql([0,1,2,3,4]); expect(results).to.eql([0,1,2,3,4]); done(); }); }); - it('timesSeries error', function(done) { - async.timesSeries(5, function(n, callback){ + it('timesSeries error', (done) => { + async.timesSeries(5, (n, callback) => { callback('error'); - }, function(err){ + }, (err) => { expect(err).to.equal('error'); }); setTimeout(done, 50); }); - it('timesLimit', function(done) { + it('timesLimit', (done) => { var limit = 2; var running = 0; - async.timesLimit(5, limit, function (i, next) { + async.timesLimit(5, limit, (i, next) => { running++; assert(running <= limit && running > 0, running); - setTimeout(function () { + setTimeout(() => { running--; next(null, i * 2); }, (3 - i) * 10); - }, function(err, results){ + }, (err, results) => { assert(err === null, err + " passed instead of 'null'"); expect(results).to.eql([0, 2, 4, 6, 8]); done(); |