node/test/internet/test-http-dns-fail.js
Adrian Estrada b9361cae6e 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: https://github.com/nodejs/node/pull/10243
Reviewed-By: Italo A. Casas <me@italoacasas.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Lance Ball <lball@redhat.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
2016-12-14 22:52:39 -05:00

29 lines
602 B
JavaScript

'use strict';
/*
* Repeated requests for a domain that fails to resolve
* should trigger the error event after each attempt.
*/
const common = require('../common');
const assert = require('assert');
const http = require('http');
function httpreq(count) {
if (count > 1) return;
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', common.mustCall((e) => {
assert.strictEqual(e.code, 'ENOTFOUND');
httpreq(count + 1);
}));
req.end();
}
httpreq(0);