mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
702 B
35 lines
702 B
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const net = require('net');
|
|
|
|
const expectedError = /^TypeError: "lookup" option should be a function$/;
|
|
|
|
['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
|
|
};
|
|
|
|
assert.throws(() => {
|
|
net.connect(opts);
|
|
}, expectedError);
|
|
}
|
|
|
|
connectDoesNotThrow(common.noop);
|
|
|
|
function connectDoesNotThrow(input) {
|
|
const opts = {
|
|
host: 'localhost',
|
|
port: 0,
|
|
lookup: input
|
|
};
|
|
|
|
assert.doesNotThrow(() => {
|
|
net.connect(opts);
|
|
});
|
|
}
|
|
|