diff options
author | asilvas <asilvas@godaddy.com> | 2016-04-05 15:28:40 -0700 |
---|---|---|
committer | asilvas <asilvas@godaddy.com> | 2016-04-05 15:28:40 -0700 |
commit | cb703585a83d48a894929c41094a33605c687f97 (patch) | |
tree | 5c521ceb9d922bdbcfcd030a2b2202799be1bc1c /test | |
parent | 5d2f19b360b7ec74db659ae571d730c1acc58b76 (diff) | |
download | async-cb703585a83d48a894929c41094a33605c687f97.tar.gz |
#1097. Named timeout for tracking purposes
Diffstat (limited to 'test')
-rwxr-xr-x | test/test-async.js | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/test/test-async.js b/test/test-async.js index 6831ac2..d36c704 100755 --- a/test/test-async.js +++ b/test/test-async.js @@ -2770,7 +2770,7 @@ exports['asyncify'] = { }; exports['timeout'] = function (test) { - test.expect(3); + test.expect(4); async.series([ async.timeout(function asyncFn(callback) { @@ -2785,15 +2785,41 @@ exports['timeout'] = function (test) { }, 150) ], function(err, results) { - test.ok(err.message === 'Callback function timed out.'); + test.ok(err.message === 'Callback function "asyncFn" timed out.'); test.ok(err.code === 'ETIMEDOUT'); + test.ok(err.info === undefined); test.ok(results[0] === 'I didn\'t time out'); test.done(); }); }; +exports['timeout with info'] = function (test) { + test.expect(4); + + var info = { custom: 'info about callback' }; + async.series([ + async.timeout(function asyncFn(callback) { + setTimeout(function() { + callback(null, 'I didn\'t time out'); + }, 50); + }, 200), + async.timeout(function asyncFn(callback) { + setTimeout(function() { + callback(null, 'I will time out'); + }, 300); + }, 150, info) + ], + function(err, results) { + test.ok(err.message === 'Callback function "asyncFn" timed out.'); + test.ok(err.code === 'ETIMEDOUT'); + test.ok(err.info === info); + test.ok(results[0] === 'I didn\'t time out'); + test.done(); + }); +}; + exports['timeout with parallel'] = function (test) { - test.expect(3); + test.expect(4); async.parallel([ async.timeout(function asyncFn(callback) { @@ -2808,8 +2834,9 @@ exports['timeout with parallel'] = function (test) { }, 150) ], function(err, results) { - test.ok(err.message === 'Callback function timed out.'); + test.ok(err.message === 'Callback function "asyncFn" timed out.'); test.ok(err.code === 'ETIMEDOUT'); + test.ok(err.info === undefined); test.ok(results[0] === 'I didn\'t time out'); test.done(); }); |