diff options
author | ezubarev <zubarev.eugene@gmail.com> | 2016-05-06 13:37:24 +0600 |
---|---|---|
committer | ezubarev <zubarev.eugene@gmail.com> | 2016-05-06 13:37:24 +0600 |
commit | 6dc73a3e0454a8c02d3b996bc908860c82d21f84 (patch) | |
tree | e41636ec4782da5c5205410ed5e52a625ff536cd /test | |
parent | e17f3d7d534dc6bf9aad530c3a3e77924a9070fe (diff) | |
download | async-6dc73a3e0454a8c02d3b996bc908860c82d21f84.tar.gz |
Convert apply/concat tests to mocha
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-async.js | 84 |
1 files changed, 0 insertions, 84 deletions
diff --git a/test/test-async.js b/test/test-async.js index ba1a6f3..694f4bc 100755 --- a/test/test-async.js +++ b/test/test-async.js @@ -6,34 +6,6 @@ require('babel-core/register'); var async = require('../lib'); -if (!Function.prototype.bind) { - Function.prototype.bind = function (thisArg) { - var args = Array.prototype.slice.call(arguments, 1); - var self = this; - return function () { - self.apply(thisArg, args.concat(Array.prototype.slice.call(arguments))); - }; - }; -} - -exports['apply'] = function(test){ - test.expect(6); - var fn = function(){ - test.same(Array.prototype.slice.call(arguments), [1,2,3,4]); - }; - async.apply(fn, 1, 2, 3, 4)(); - async.apply(fn, 1, 2, 3)(4); - async.apply(fn, 1, 2)(3, 4); - async.apply(fn, 1)(2, 3, 4); - async.apply(fn)(1, 2, 3, 4); - test.equals( - async.apply(function(name){return 'hello ' + name;}, 'world')(), - 'hello world' - ); - test.done(); -}; - - // generates tests for console functions such as async.log var console_fn_tests = function(name){ @@ -100,59 +72,3 @@ console_fn_tests('dir'); /*console_fn_tests('info'); console_fn_tests('warn'); console_fn_tests('error');*/ - - -exports['concat'] = function(test){ - test.expect(3); - var call_order = []; - var iteratee = function (x, cb) { - setTimeout(function(){ - call_order.push(x); - var r = []; - while (x > 0) { - r.push(x); - x--; - } - cb(null, r); - }, x*25); - }; - async.concat([1,3,2], iteratee, function(err, results){ - test.same(results, [1,2,1,3,2,1]); - test.same(call_order, [1,2,3]); - test.ok(err === null, err + " passed instead of 'null'"); - test.done(); - }); -}; - -exports['concat error'] = function(test){ - test.expect(1); - var iteratee = function (x, cb) { - cb(new Error('test error')); - }; - async.concat([1,2,3], iteratee, function(err){ - test.ok(err); - test.done(); - }); -}; - -exports['concatSeries'] = function(test){ - test.expect(3); - var call_order = []; - var iteratee = function (x, cb) { - setTimeout(function(){ - call_order.push(x); - var r = []; - while (x > 0) { - r.push(x); - x--; - } - cb(null, r); - }, x*25); - }; - async.concatSeries([1,3,2], iteratee, function(err, results){ - test.same(results, [1,3,2,1,2,1]); - test.same(call_order, [1,3,2]); - test.ok(err === null, err + " passed instead of 'null'"); - test.done(); - }); -}; |