diff options
author | U-Zyn Chua <chua@uzyn.com> | 2015-06-23 22:25:02 +0800 |
---|---|---|
committer | U-Zyn Chua <chua@uzyn.com> | 2015-06-23 22:25:02 +0800 |
commit | ea3576b6da334710d0da7446064e9acc0766136a (patch) | |
tree | 9783f8c78f4019b5869e2051de27b71259b81347 /test/test-async.js | |
parent | bd8325fb5b07b296733f1638fa8dcd7b8fc684cd (diff) | |
download | async-ea3576b6da334710d0da7446064e9acc0766136a.tar.gz |
during & doDuring with async test
Diffstat (limited to 'test/test-async.js')
-rwxr-xr-x | test/test-async.js | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/test/test-async.js b/test/test-async.js index 8b2f87f..2d7269b 100755 --- a/test/test-async.js +++ b/test/test-async.js @@ -2811,6 +2811,65 @@ exports['doWhilst callback params'] = function (test) { ); }; +exports['during'] = function (test) { + var call_order = []; + + var count = 0; + async.during( + function (cb) { + call_order.push(['test', count]); + cb(count < 5); + }, + function (cb) { + call_order.push(['iterator', count]); + count++; + cb(); + }, + function (err) { + test.ok(err === null, err + " passed instead of 'null'"); + test.same(call_order, [ + ['test', 0], + ['iterator', 0], ['test', 1], + ['iterator', 1], ['test', 2], + ['iterator', 2], ['test', 3], + ['iterator', 3], ['test', 4], + ['iterator', 4], ['test', 5], + ]); + test.equals(count, 5); + test.done(); + } + ); +}; + +exports['doDuring'] = function (test) { + var call_order = []; + + var count = 0; + async.doDuring( + function (cb) { + call_order.push(['iterator', count]); + count++; + cb(); + }, + function (cb) { + call_order.push(['test', count]); + cb(count < 5); + }, + function (err) { + test.ok(err === null, err + " passed instead of 'null'"); + test.same(call_order, [ + ['iterator', 0], ['test', 1], + ['iterator', 1], ['test', 2], + ['iterator', 2], ['test', 3], + ['iterator', 3], ['test', 4], + ['iterator', 4], ['test', 5], + ]); + test.equals(count, 5); + test.done(); + } + ); +}; + exports['queue'] = { 'queue': function (test) { |