aboutsummaryrefslogtreecommitdiff
path: root/test/parallel/test-stream-readable-invalid-chunk.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/parallel/test-stream-readable-invalid-chunk.js')
-rw-r--r--test/parallel/test-stream-readable-invalid-chunk.js33
1 files changed, 24 insertions, 9 deletions
diff --git a/test/parallel/test-stream-readable-invalid-chunk.js b/test/parallel/test-stream-readable-invalid-chunk.js
index fcd7414bb6..3e147c065f 100644
--- a/test/parallel/test-stream-readable-invalid-chunk.js
+++ b/test/parallel/test-stream-readable-invalid-chunk.js
@@ -3,17 +3,32 @@
const common = require('../common');
const stream = require('stream');
-const readable = new stream.Readable({
- read: () => {}
-});
-
-function checkError(fn) {
- common.expectsError(fn, {
+function testPushArg(val) {
+ const readable = new stream.Readable({
+ read: () => {}
+ });
+ readable.on('error', common.expectsError({
code: 'ERR_INVALID_ARG_TYPE',
type: TypeError
+ }));
+ readable.push(val);
+}
+
+testPushArg([]);
+testPushArg({});
+testPushArg(0);
+
+function testUnshiftArg(val) {
+ const readable = new stream.Readable({
+ read: () => {}
});
+ readable.on('error', common.expectsError({
+ code: 'ERR_INVALID_ARG_TYPE',
+ type: TypeError
+ }));
+ readable.unshift(val);
}
-checkError(() => readable.push([]));
-checkError(() => readable.push({}));
-checkError(() => readable.push(0));
+testUnshiftArg([]);
+testUnshiftArg({});
+testUnshiftArg(0);