From 031e00f22e8672e152d8f2bc58968a940840bbf9 Mon Sep 17 00:00:00 2001 From: Salakar Date: Thu, 6 Feb 2020 22:13:22 +0000 Subject: [PATCH] tests: fix socket timeout test Node <= 4 --- test/connection.spec.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/test/connection.spec.js b/test/connection.spec.js index f467f19578..f6dc8310cb 100644 --- a/test/connection.spec.js +++ b/test/connection.spec.js @@ -401,10 +401,22 @@ describe('connection tests', function () { connect_timeout: 1000 }); process.nextTick(function () { - assert.strictEqual(client.stream.timeout, 1000); + // node > 4 + var timeout = client.stream.timeout; + // node <= 4 + if (timeout === undefined) timeout = client.stream._idleTimeout; + assert.strictEqual(timeout, 1000); }); client.on('connect', function () { - assert.strictEqual(client.stream.timeout, 0); + // node > 4 + var expected = 0; + var timeout = client.stream.timeout; + // node <= 4 + if (timeout === undefined) { + timeout = client.stream._idleTimeout; + expected = -1; + } + assert.strictEqual(timeout, expected); assert.strictEqual(client.stream.listeners('timeout').length, 0); client.on('ready', done); });