Skip to content

Commit 7af9004

Browse files
author
Ruben Bridgewater
committed
Improve test
1 parent a8e7d59 commit 7af9004

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

test/auth.spec.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,10 @@ describe("client authentication", function () {
5252
var time = Date.now();
5353
client.auth(auth, function (err, res) {
5454
assert.strictEqual('retry worked', res);
55-
assert(Date.now() - time >= 200, 'Time should be above 200 ms (the reconnect time)');
56-
assert(Date.now() - time < 300, 'Time should be below 300 ms (the reconnect should only take a bit above 200 ms)');
55+
var now = Date.now();
56+
// Hint: setTimeout sometimes triggers early and therefor the value can be like one or two ms to early
57+
assert(now - time >= 198, 'Time should be above 200 ms (the reconnect time) and is ' + (now - time));
58+
assert(now - time < 300, 'Time should be below 300 ms (the reconnect should only take a bit above 200 ms) and is ' + (now - time));
5759
done();
5860
});
5961
var tmp = client.command_queue.get(0).callback;

0 commit comments

Comments
 (0)