test: ignore connection errors for hostname check

PR-URL: https://github.com/nodejs/node/pull/14073
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
Refael Ackermann authored and Jeremiah Senkpiel committed 2017-07-19 15:02:21 -04:00
1 parent 0a462fbcbf
commit 628fc498d5
1 file changed
+5 -3
@@ -18,10 +18,12 @@ vals.forEach((v) => {
assert.throws(() => http.request({host: v}), errHost);
});
// These values are OK and should not throw synchronously
// These values are OK and should not throw synchronously.
// Only testing for 'hostname' validation so ignore connection errors.
const dontCare = () => {};
['', undefined, null].forEach((v) => {
assert.doesNotThrow(() => {
http.request({hostname: v}).on('error', () => {}).end();
http.request({host: v}).on('error', () => {}).end();
http.request({hostname: v}).on('error', dontCare).end();
http.request({host: v}).on('error', dontCare).end();
});
});