mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
node: fix test-net-connect-options-invalid.js (#17824)
This commit is contained in:
@@ -517,6 +517,13 @@ const Socket = (function (InternalSocket) {
|
||||
...opts
|
||||
} = options || {};
|
||||
|
||||
if (options?.objectMode)
|
||||
throw $ERR_INVALID_ARG_VALUE("options.objectMode", options.objectMode, "is not supported");
|
||||
if (options?.readableObjectMode)
|
||||
throw $ERR_INVALID_ARG_VALUE("options.readableObjectMode", options.readableObjectMode, "is not supported");
|
||||
if (options?.writableObjectMode)
|
||||
throw $ERR_INVALID_ARG_VALUE("options.writableObjectMode", options.writableObjectMode, "is not supported");
|
||||
|
||||
super({
|
||||
...opts,
|
||||
allowHalfOpen,
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
require('../common');
|
||||
const assert = require('assert');
|
||||
const net = require('net');
|
||||
|
||||
{
|
||||
const invalidKeys = [
|
||||
'objectMode',
|
||||
'readableObjectMode',
|
||||
'writableObjectMode',
|
||||
];
|
||||
invalidKeys.forEach((invalidKey) => {
|
||||
const option = {
|
||||
port: 8080,
|
||||
[invalidKey]: true
|
||||
};
|
||||
const message = `The property 'options.${invalidKey}' is not supported. Received true`;
|
||||
|
||||
assert.throws(() => {
|
||||
net.createConnection(option);
|
||||
}, {
|
||||
code: 'ERR_INVALID_ARG_VALUE',
|
||||
name: 'TypeError',
|
||||
message: new RegExp(message)
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user