Skip to content

Commit b9361ca

Browse files
edsadrMylesBorins
authored andcommitted
test: refactor test-http-dns-fail
* remove counter used to control function execution * use commont.mustCall to control the function execution * use const and let instead of var * use arrow functions PR-URL: #10243 Reviewed-By: Italo A. Casas <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Lance Ball <[email protected]> Reviewed-By: Brian White <[email protected]>
1 parent 2673be6 commit b9361ca

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

test/internet/test-http-dns-fail.js

+6-15
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,25 @@
55
*/
66

77
const common = require('../common');
8-
var assert = require('assert');
9-
var http = require('http');
10-
11-
var hadError = 0;
8+
const assert = require('assert');
9+
const http = require('http');
1210

1311
function httpreq(count) {
14-
if (1 < count) return;
12+
if (count > 1) return;
1513

16-
var req = http.request({
14+
const req = http.request({
1715
host: 'not-a-real-domain-name.nobody-would-register-this-as-a-tld',
1816
port: 80,
1917
path: '/',
2018
method: 'GET'
2119
}, common.fail);
2220

23-
req.on('error', function(e) {
24-
console.log(e.message);
21+
req.on('error', common.mustCall((e) => {
2522
assert.strictEqual(e.code, 'ENOTFOUND');
26-
hadError++;
2723
httpreq(count + 1);
28-
});
24+
}));
2925

3026
req.end();
3127
}
3228

3329
httpreq(0);
34-
35-
36-
process.on('exit', function() {
37-
assert.equal(2, hadError);
38-
});

0 commit comments

Comments
 (0)