node/test/parallel/test-net-localerror.js
Daniel Flores 4a204ee24c test: Update to const and use regex for assertions
Use const over var.

Assert error message with regex.

PR-URL: https://github.com/nodejs/node/pull/9891
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2016-12-04 15:20:47 -08:00

23 lines
499 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const net = require('net');
connect({
host: 'localhost',
port: common.PORT,
localPort: 'foobar',
}, /^TypeError: "localPort" option should be a number: foobar$/);
connect({
host: 'localhost',
port: common.PORT,
localAddress: 'foobar',
}, /^TypeError: "localAddress" option must be a valid IP: foobar$/);
function connect(opts, msg) {
assert.throws(function() {
net.connect(opts);
}, msg);
}