Browse Source

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>
v6
Refael Ackermann 8 years ago
parent
commit
4d7946aec3
No known key found for this signature in database GPG Key ID: CD704BD80FDDDB64
  1. 8
      test/parallel/test-http-hostname-typechecking.js

8
test/parallel/test-http-hostname-typechecking.js

@ -18,10 +18,12 @@ vals.forEach((v) => {
assert.throws(() => http.request({host: v}), errHost); 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) => { ['', undefined, null].forEach((v) => {
assert.doesNotThrow(() => { assert.doesNotThrow(() => {
http.request({hostname: v}).on('error', () => {}).end(); http.request({hostname: v}).on('error', dontCare).end();
http.request({host: v}).on('error', () => {}).end(); http.request({host: v}).on('error', dontCare).end();
}); });
}); });

Loading…
Cancel
Save