Skip to content

Commit 031e00f

Browse files
committed
tests: fix socket timeout test Node <= 4
1 parent 5be0d3a commit 031e00f

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

test/connection.spec.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -401,10 +401,22 @@ describe('connection tests', function () {
401401
connect_timeout: 1000
402402
});
403403
process.nextTick(function () {
404-
assert.strictEqual(client.stream.timeout, 1000);
404+
// node > 4
405+
var timeout = client.stream.timeout;
406+
// node <= 4
407+
if (timeout === undefined) timeout = client.stream._idleTimeout;
408+
assert.strictEqual(timeout, 1000);
405409
});
406410
client.on('connect', function () {
407-
assert.strictEqual(client.stream.timeout, 0);
411+
// node > 4
412+
var expected = 0;
413+
var timeout = client.stream.timeout;
414+
// node <= 4
415+
if (timeout === undefined) {
416+
timeout = client.stream._idleTimeout;
417+
expected = -1;
418+
}
419+
assert.strictEqual(timeout, expected);
408420
assert.strictEqual(client.stream.listeners('timeout').length, 0);
409421
client.on('ready', done);
410422
});

0 commit comments

Comments
 (0)