From c95e65189802dd7c227b7608d26c45c02ed5bfd8 Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 5 Dec 2018 14:38:55 -0800 Subject: [PATCH] test: improve test-net-socket-timeout * Check for custom Node.js code rather than constructor in assert.throws(). * Use arrow functions consistently. PR-URL: https://github.com/nodejs/node/pull/24859 Reviewed-By: Colin Ihrig Reviewed-By: Richard Lau Reviewed-By: Trivikram Kamat --- test/parallel/test-net-socket-timeout.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/parallel/test-net-socket-timeout.js b/test/parallel/test-net-socket-timeout.js index 2826b1dd76f146..a30ab8ce293764 100644 --- a/test/parallel/test-net-socket-timeout.js +++ b/test/parallel/test-net-socket-timeout.js @@ -34,15 +34,15 @@ const validDelays = [0, 0.001, 1, 1e6]; for (let i = 0; i < nonNumericDelays.length; i++) { - assert.throws(function() { + assert.throws(() => { s.setTimeout(nonNumericDelays[i], () => {}); - }, TypeError, nonNumericDelays[i]); + }, { code: 'ERR_INVALID_ARG_TYPE' }, nonNumericDelays[i]); } for (let i = 0; i < badRangeDelays.length; i++) { - assert.throws(function() { + assert.throws(() => { s.setTimeout(badRangeDelays[i], () => {}); - }, RangeError, badRangeDelays[i]); + }, { code: 'ERR_OUT_OF_RANGE' }, badRangeDelays[i]); } for (let i = 0; i < validDelays.length; i++) { @@ -50,9 +50,9 @@ for (let i = 0; i < validDelays.length; i++) { } const server = net.Server(); -server.listen(0, common.mustCall(function() { - const socket = net.createConnection(this.address().port); - socket.setTimeout(1, common.mustCall(function() { +server.listen(0, common.mustCall(() => { + const socket = net.createConnection(server.address().port); + socket.setTimeout(1, common.mustCall(() => { socket.destroy(); server.close(); }));