summaryrefslogtreecommitdiff
path: root/mocha_test/retry.js
diff options
context:
space:
mode:
authorAlexander Early <alexander.early@gmail.com>2018-04-14 20:10:29 -0700
committerAlexander Early <alexander.early@gmail.com>2018-04-14 20:10:29 -0700
commit45e2938cfa536fe27898c60a4e0fe37080c880bb (patch)
treec0cb0776b596908d1a79f77c1a30a138dcba6a00 /mocha_test/retry.js
parent2030f5f1bd01a141ac4c85d3deab927f49e255fc (diff)
parent3235c8f5f67ff38b85ce6f9664053d0b1897ff3b (diff)
downloadasync-DELETE_THIS_BRANCH.tar.gz
Merge branch 'master' into DELETE_THIS_BRANCHDELETE_THIS_BRANCH
Diffstat (limited to 'mocha_test/retry.js')
-rw-r--r--mocha_test/retry.js23
1 files changed, 10 insertions, 13 deletions
diff --git a/mocha_test/retry.js b/mocha_test/retry.js
index d3a5d22..8a9f4da 100644
--- a/mocha_test/retry.js
+++ b/mocha_test/retry.js
@@ -66,11 +66,10 @@ describe("retry", function () {
callCount++;
callback(error + callCount, erroredResult + callCount); // respond with indexed values
}
- var start = new Date().getTime();
+ var start = Date.now();
async.retry({ times: times, interval: interval}, fn, function(err, result){
- var now = new Date().getTime();
- var duration = now - start;
- assert(duration >= (interval * (times -1)), 'did not include interval');
+ var duration = Date.now() - start;
+ expect(duration).to.be.above(interval * (times - 1) - times);
assert.equal(callCount, 3, "did not retry the correct number of times");
assert.equal(err, error + times, "Incorrect error was returned");
assert.equal(result, erroredResult + times, "Incorrect result was returned");
@@ -88,11 +87,10 @@ describe("retry", function () {
callCount++;
callback(error + callCount, erroredResult + callCount); // respond with indexed values
}
- var start = new Date().getTime();
+ var start = Date.now();
async.retry({ times: times, interval: intervalFunc}, fn, function(err, result){
- var now = new Date().getTime();
- var duration = now - start;
- assert(duration >= 300, 'did not include custom interval');
+ var duration = Date.now() - start;
+ expect(duration).to.be.above(300 - times);
assert.equal(callCount, 3, "did not retry the correct number of times");
assert.equal(err, error + times, "Incorrect error was returned");
assert.equal(result, erroredResult + times, "Incorrect result was returned");
@@ -127,7 +125,7 @@ describe("retry", function () {
it('retry does not precompute the intervals (#1226)', function(done) {
var callTimes = [];
function intervalFunc() {
- callTimes.push(new Date().getTime());
+ callTimes.push(Date.now());
return 100;
};
function fn(callback) {
@@ -226,11 +224,10 @@ describe("retry", function () {
function errorTest(err) {
return err && err !== special;
}
- var start = new Date().getTime();
+ var start = Date.now();
async.retry({ interval: interval, errorFilter: errorTest }, fn, function(err, result){
- var now = new Date().getTime();
- var duration = now - start;
- assert(duration >= (interval * (specialCount - 1)), 'did not include interval');
+ var duration = Date.now() - start;
+ expect(duration).to.be.above(interval * (specialCount - 1) - specialCount);
assert.equal(callCount, specialCount, "did not retry the correct number of times");
assert.equal(err, special, "Incorrect error was returned");
assert.equal(result, erroredResult + specialCount, "Incorrect result was returned");