diff options
Diffstat (limited to 'test/some.js')
-rw-r--r-- | test/some.js | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/test/some.js b/test/some.js index 989fecb..5b54ec3 100644 --- a/test/some.js +++ b/test/some.js @@ -2,94 +2,94 @@ var async = require('../lib'); var expect = require('chai').expect; var _ = require('lodash'); -describe("some", function () { +describe("some", () => { - it('some true', function(done){ - async.some([3,1,2], function(x, callback){ - setTimeout(function(){callback(null, x === 1);}, 0); - }, function(err, result){ + it('some true', (done) => { + async.some([3,1,2], (x, callback) => { + setTimeout(() => {callback(null, x === 1);}, 0); + }, (err, result) => { expect(err).to.equal(null); expect(result).to.equal(true); done(); }); }); - it('some false', function(done){ - async.some([3,1,2], function(x, callback){ - setTimeout(function(){callback(null, x === 10);}, 0); - }, function(err, result){ + it('some false', (done) => { + async.some([3,1,2], (x, callback) => { + setTimeout(() => {callback(null, x === 10);}, 0); + }, (err, result) => { expect(err).to.equal(null); expect(result).to.equal(false); done(); }); }); - it('some early return', function(done){ + it('some early return', (done) => { var call_order = []; - async.some([1,2,3], function(x, callback){ - setTimeout(function(){ + async.some([1,2,3], (x, callback) => { + setTimeout(() => { call_order.push(x); callback(null, x === 1); }, x*5); - }, function(){ + }, () => { call_order.push('callback'); }); - setTimeout(function(){ + setTimeout(() => { expect(call_order).to.eql([1,'callback',2,3]); done(); }, 25); }); - it('some error', function(done){ - async.some([3,1,2], function(x, callback){ - setTimeout(function(){callback('error');}, 0); - }, function(err, result){ + it('some error', (done) => { + async.some([3,1,2], (x, callback) => { + setTimeout(() => {callback('error');}, 0); + }, (err, result) => { expect(err).to.equal('error'); expect(result).to.not.exist; done(); }); }); - it('some no callback', function(done) { + it('some no callback', (done) => { var calls = []; - async.some([1, 2, 3], function (val, cb) { + async.some([1, 2, 3], (val, cb) => { calls.push(val); cb(); }); - setTimeout(function () { + setTimeout(() => { expect(calls).to.eql([1, 2, 3]); done(); }, 10); }); - it('someLimit true', function(done){ - async.someLimit([3,1,2], 2, function(x, callback){ - setTimeout(function(){callback(null, x === 2);}, 0); - }, function(err, result){ + it('someLimit true', (done) => { + async.someLimit([3,1,2], 2, (x, callback) => { + setTimeout(() => {callback(null, x === 2);}, 0); + }, (err, result) => { expect(err).to.equal(null); expect(result).to.equal(true); done(); }); }); - it('someLimit false', function(done){ - async.someLimit([3,1,2], 2, function(x, callback){ - setTimeout(function(){callback(null, x === 10);}, 0); - }, function(err, result){ + it('someLimit false', (done) => { + async.someLimit([3,1,2], 2, (x, callback) => { + setTimeout(() => {callback(null, x === 10);}, 0); + }, (err, result) => { expect(err).to.equal(null); expect(result).to.equal(false); done(); }); }); - it('someLimit short-circuit', function(done){ + it('someLimit short-circuit', (done) => { var calls = 0; - async.someLimit([3,1,2], 1, function(x, callback){ + async.someLimit([3,1,2], 1, (x, callback) => { calls++; callback(null, x === 1); - }, function(err, result){ + }, (err, result) => { expect(err).to.equal(null); expect(result).to.equal(true); expect(calls).to.equal(2); @@ -98,41 +98,41 @@ describe("some", function () { }); - it('someSeries doesn\'t cause stack overflow (#1293)', function(done) { + it('someSeries doesn\'t cause stack overflow (#1293)', (done) => { var arr = _.range(10000); let calls = 0; - async.someSeries(arr, function(data, cb) { + async.someSeries(arr, (data, cb) => { calls += 1; async.setImmediate(_.partial(cb, null, true)); - }, function(err) { + }, (err) => { expect(err).to.equal(null); expect(calls).to.equal(1); done(); }); }); - it('someLimit doesn\'t cause stack overflow (#1293)', function(done) { + it('someLimit doesn\'t cause stack overflow (#1293)', (done) => { var arr = _.range(10000); let calls = 0; - async.someLimit(arr, 100, function(data, cb) { + async.someLimit(arr, 100, (data, cb) => { calls += 1; async.setImmediate(_.partial(cb, null, true)); - }, function(err) { + }, (err) => { expect(err).to.equal(null); expect(calls).to.equal(100); done(); }); }); - it('any alias', function(){ + it('any alias', () => { expect(async.any).to.equal(async.some); }); - it('anyLimit alias', function(){ + it('anyLimit alias', () => { expect(async.anyLimit).to.equal(async.someLimit); }); - it('anySeries alias', function(){ + it('anySeries alias', () => { expect(async.anySeries).to.be.a('function'); expect(async.anySeries).to.equal(async.someSeries); }); |