@@ -4,17 +4,17 @@ const assert = require('assert');
4
4
5
5
const { Writable } = require ( 'stream' ) ;
6
6
7
- function expectError ( w , arg , code , sync ) {
7
+ function expectError ( w , args , code , sync ) {
8
8
if ( sync ) {
9
9
if ( code ) {
10
- assert . throws ( ( ) => w . write ( arg ) , { code } ) ;
10
+ assert . throws ( ( ) => w . write ( ... args ) , { code } ) ;
11
11
} else {
12
- w . write ( arg ) ;
12
+ w . write ( ... args ) ;
13
13
}
14
14
} else {
15
15
let errorCalled = false ;
16
16
let ticked = false ;
17
- w . write ( arg , common . mustCall ( ( err ) => {
17
+ w . write ( ... args , common . mustCall ( ( err ) => {
18
18
assert . strictEqual ( ticked , true ) ;
19
19
assert . strictEqual ( errorCalled , false ) ;
20
20
assert . strictEqual ( err . code , code ) ;
@@ -34,7 +34,7 @@ function test(autoDestroy) {
34
34
_write ( ) { }
35
35
} ) ;
36
36
w . end ( ) ;
37
- expectError ( w , 'asd' , 'ERR_STREAM_WRITE_AFTER_END' ) ;
37
+ expectError ( w , [ 'asd' ] , 'ERR_STREAM_WRITE_AFTER_END' ) ;
38
38
}
39
39
40
40
{
@@ -50,15 +50,23 @@ function test(autoDestroy) {
50
50
autoDestroy,
51
51
_write ( ) { }
52
52
} ) ;
53
- expectError ( w , null , 'ERR_STREAM_NULL_VALUES' , true ) ;
53
+ expectError ( w , [ null ] , 'ERR_STREAM_NULL_VALUES' , true ) ;
54
54
}
55
55
56
56
{
57
57
const w = new Writable ( {
58
58
autoDestroy,
59
59
_write ( ) { }
60
60
} ) ;
61
- expectError ( w , { } , 'ERR_INVALID_ARG_TYPE' , true ) ;
61
+ expectError ( w , [ { } ] , 'ERR_INVALID_ARG_TYPE' , true ) ;
62
+ }
63
+
64
+ {
65
+ const w = new Writable ( {
66
+ autoDestroy,
67
+ _write ( ) { }
68
+ } ) ;
69
+ expectError ( w , [ 'asd' , 'noencoding' ] , 'ERR_UNKNOWN_ENCODING' , true ) ;
62
70
}
63
71
}
64
72
0 commit comments