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 <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
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‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,25 +34,25 @@ const validDelays = [0, 0.001, 1, 1e6];
3434

3535

3636
for(leti=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(leti=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(leti=0;i<validDelays.length;i++){
4949
s.setTimeout(validDelays[i],()=>{});
5050
}
5151

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

0 commit comments

Comments
(0)