Skip to content

Commit 6db760c

Browse files
Trotttargos
authored andcommitted
test: improve test-net-socket-timeout
* Check for custom Node.js code rather than constructor in assert.throws(). * Use arrow functions consistently. PR-URL: #24859 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
1 parent 643ca14 commit 6db760c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

test/parallel/test-net-socket-timeout.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,25 @@ const validDelays = [0, 0.001, 1, 1e6];
3434

3535

3636
for (let i = 0; i < nonNumericDelays.length; i++) {
37-
assert.throws(function() {
37+
assert.throws(() => {
3838
s.setTimeout(nonNumericDelays[i], () => {});
39-
}, TypeError, nonNumericDelays[i]);
39+
}, { code: 'ERR_INVALID_ARG_TYPE' }, nonNumericDelays[i]);
4040
}
4141

4242
for (let i = 0; i < badRangeDelays.length; i++) {
43-
assert.throws(function() {
43+
assert.throws(() => {
4444
s.setTimeout(badRangeDelays[i], () => {});
45-
}, RangeError, badRangeDelays[i]);
45+
}, { code: 'ERR_OUT_OF_RANGE' }, badRangeDelays[i]);
4646
}
4747

4848
for (let i = 0; i < validDelays.length; i++) {
4949
s.setTimeout(validDelays[i], () => {});
5050
}
5151

5252
const server = net.Server();
53-
server.listen(0, common.mustCall(function() {
54-
const socket = net.createConnection(this.address().port);
55-
socket.setTimeout(1, common.mustCall(function() {
53+
server.listen(0, common.mustCall(() => {
54+
const socket = net.createConnection(server.address().port);
55+
socket.setTimeout(1, common.mustCall(() => {
5656
socket.destroy();
5757
server.close();
5858
}));

0 commit comments

Comments
 (0)