summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoredeustace <ed.eustace@gmail.com>2015-06-17 11:46:38 +0100
committeredeustace <ed.eustace@gmail.com>2015-06-17 11:46:38 +0100
commitdac52c832159179967cc4252dd2bd7db37d65682 (patch)
tree8356915fad2b37aa6ac87c548db1a91b22643987 /test
parent41ff5496cac6e10bbaabf67856fa40111429d2b8 (diff)
downloadasync-dac52c832159179967cc4252dd2bd7db37d65682.tar.gz
move interval to options object that may be passed in as the 1st parameter
Diffstat (limited to 'test')
-rwxr-xr-xtest/test-async.js22
1 files changed, 20 insertions, 2 deletions
diff --git a/test/test-async.js b/test/test-async.js
index b74e84f..5b6f803 100755
--- a/test/test-async.js
+++ b/test/test-async.js
@@ -739,7 +739,7 @@ exports['retry with interval when all attempts succeeds'] = function(test) {
callback(error + callCount, erroredResult + callCount); // respond with indexed values
}
var start = new Date().getTime();
- async.retry(times, fn, function(err, result){
+ async.retry({ times: times, interval: interval}, fn, function(err, result){
var now = new Date().getTime();
var duration = now - start;
test.ok(duration > (interval * (times -1)), 'did not include interval');
@@ -747,7 +747,7 @@ exports['retry with interval when all attempts succeeds'] = function(test) {
test.equal(err, error + times, "Incorrect error was returned");
test.equal(result, erroredResult + times, "Incorrect result was returned");
test.done();
- }, interval);
+ });
};
exports['retry as an embedded task'] = function(test) {
@@ -771,6 +771,24 @@ exports['retry as an embedded task'] = function(test) {
});
};
+exports['retry as an embedded task with interval'] = function(test) {
+ var start = new Date().getTime();
+ var opts = {times: 5, interval: 100};
+
+ async.auto({
+ foo: function(callback){
+ callback(null, 'FOO');
+ },
+ retry: async.retry(opts, function(callback) {
+ callback('err');
+ })
+ }, function(){
+ var duration = new Date().getTime() - start;
+ test.ok(duration > ((opts.times -1) * opts.interval), "The duration should have been greater than ((times -1) * interval)");
+ test.done();
+ });
+};
+
exports['waterfall'] = {
'basic': function(test){