node/test/parallel/test-socket-options-invalid.js
Daijiro Wachi e0faf8c3e9 test: replace common port with specific number
PR-URL: https://github.com/nodejs/node/pull/40344
Fixes: https://github.com/nodejs/node/issues/40336
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
Reviewed-By: Zijian Liu <lxxyxzj@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
2021-10-13 01:45:03 +00:00

28 lines
617 B
JavaScript

'use strict';
require('../common');
const assert = require('assert');
const net = require('net');
{
const invalidKeys = [
'objectMode',
'readableObjectMode',
'writableObjectMode',
];
invalidKeys.forEach((invalidKey) => {
const option = {
[invalidKey]: true
};
const message = `The property 'options.${invalidKey}' is not supported. Received true`;
assert.throws(() => {
const socket = new net.Socket(option);
socket.connect({ port: 8080 });
}, {
code: 'ERR_INVALID_ARG_VALUE',
name: 'TypeError',
message: new RegExp(message)
});
});
}