forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
net: throw error to object mode in Socket
Fixes: nodejs#40336
- Loading branch information
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
'use strict'; | ||
const common = require('../common'); | ||
const assert = require('assert'); | ||
const net = require('net'); | ||
|
||
{ | ||
const invalidKeys = [ | ||
'objectMode', | ||
'readableObjectMode', | ||
'writableObjectMode', | ||
]; | ||
invalidKeys.forEach((invalidKey) => { | ||
const option = { | ||
...common.localhostIPv4, | ||
[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) | ||
}); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
'use strict'; | ||
const common = 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.objectMode' is not supported. Received true`; | ||
|
||
assert.throws(() => { | ||
const socket = new net.Socket({ objectMode: true }); | ||
}, { | ||
code: 'ERR_INVALID_ARG_VALUE', | ||
name: 'TypeError', | ||
message: new RegExp(message) | ||
}); | ||
}); | ||
} |