mirror of
https://github.com/nodejs/node.git
synced 2025-05-06 01:43:00 +00:00

PR-URL: https://github.com/nodejs/node/pull/17498 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Jon Moss <me@jonathanmoss.me>
37 lines
675 B
JavaScript
37 lines
675 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
['foobar', 1, {}, []].forEach((input) => connectThrows(input));
|
|
|
|
// Using port 0 as lookup is emitted before connecting.
|
|
function connectThrows(input) {
|
|
const opts = {
|
|
host: 'localhost',
|
|
port: 0,
|
|
lookup: input
|
|
};
|
|
|
|
common.expectsError(() => {
|
|
net.connect(opts);
|
|
}, {
|
|
code: 'ERR_INVALID_ARG_TYPE',
|
|
type: TypeError
|
|
});
|
|
}
|
|
|
|
connectDoesNotThrow(() => {});
|
|
|
|
function connectDoesNotThrow(input) {
|
|
const opts = {
|
|
host: 'localhost',
|
|
port: 0,
|
|
lookup: input
|
|
};
|
|
|
|
assert.doesNotThrow(() => {
|
|
net.connect(opts);
|
|
});
|
|
}
|