node/test/parallel/test-net-localerror.js
Daniel Flores 2a8d29339d
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-05 03:35:38 +01:00

22 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);
}