Skip to content

Commit 4fce855

Browse files
julianduqueaddaleax
authored andcommitted
test: refactor test for net listen on fd0
Replace var to const/let, use common.mustCall on callbacks and move process.on('exit') to the .on('error') handler PR-URL: #10025 Reviewed-By: Santiago Gimeno <[email protected]> Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent b7619e3 commit 4fce855

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed
Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
'use strict';
2-
varcommon=require('../common');
3-
varassert=require('assert');
4-
varnet=require('net');
2+
constcommon=require('../common');
3+
constassert=require('assert');
4+
constnet=require('net');
55

6-
vargotError=false;
7-
8-
process.on('exit',function(){
9-
assert(gotErrorinstanceofError);
10-
});
11-
12-
// this should fail with an async EINVAL error, not throw an exception
13-
net.createServer(common.fail).listen({fd: 0}).on('error',function(e){
14-
switch(e.code){
15-
case'EINVAL':
16-
case'ENOTSOCK':
17-
gotError=e;
18-
break;
19-
}
20-
});
6+
// This should fail with an async EINVAL error, not throw an exception
7+
net.createServer(common.fail)
8+
.listen({fd: 0})
9+
.on('error',common.mustCall(function(e){
10+
assert(einstanceofError);
11+
assert(['EINVAL','ENOTSOCK'].includes(e.code));
12+
}));

0 commit comments

Comments
(0)