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 <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
parent
63469ed15c
commit
6780683a7a
@ -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();
|
||||
}));
|
||||
|
Loading…
x
Reference in New Issue
Block a user