From db029f2ab738592f97725909919b98a6e8e6c14c Mon Sep 17 00:00:00 2001 From: Adrian Estrada Date: Mon, 12 Dec 2016 18:04:05 -0500 Subject: [PATCH] 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 --- test/internet/test-http-dns-fail.js | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/test/internet/test-http-dns-fail.js b/test/internet/test-http-dns-fail.js index c83b89f8ccd37e..37abe6ed14b70b 100644 --- a/test/internet/test-http-dns-fail.js +++ b/test/internet/test-http-dns-fail.js @@ -5,34 +5,25 @@ */ const common = require('../common'); -var assert = require('assert'); -var http = require('http'); - -var hadError = 0; +const assert = require('assert'); +const http = require('http'); function httpreq(count) { - if (1 < count) return; + if (count > 1) return; - var req = http.request({ + const req = http.request({ host: 'not-a-real-domain-name.nobody-would-register-this-as-a-tld', port: 80, path: '/', method: 'GET' }, common.fail); - req.on('error', function(e) { - console.log(e.message); + req.on('error', common.mustCall((e) => { assert.strictEqual(e.code, 'ENOTFOUND'); - hadError++; httpreq(count + 1); - }); + })); req.end(); } httpreq(0); - - -process.on('exit', function() { - assert.equal(2, hadError); -});