Skip to content

Commit 990a19f

Browse files
julianduqueFishrock123
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 7fd8833 commit 990a19f

File tree

1 file changed

+10
-18
lines changed

1 file changed

+10
-18
lines changed

test/parallel/test-net-listen-fd0.js

+10-18
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
'use strict';
2-
var common = require('../common');
3-
var assert = require('assert');
4-
var net = require('net');
2+
const common = require('../common');
3+
const assert = require('assert');
4+
const net = require('net');
55

6-
var gotError = false;
7-
8-
process.on('exit', function() {
9-
assert(gotError instanceof Error);
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(e instanceof Error);
11+
assert(['EINVAL', 'ENOTSOCK'].includes(e.code));
12+
}));

0 commit comments

Comments
 (0)