@@ -4,32 +4,44 @@ const assert = require('assert');
4
4
const fs = require ( 'fs' ) ;
5
5
const path = require ( 'path' ) ;
6
6
7
+ const numberError = new RegExp ( '^TypeError: "options" must be a string ' +
8
+ 'or an object, got number instead.$' ) ;
9
+
10
+ const booleanError = new RegExp ( '^TypeError: "options" must be a string ' +
11
+ 'or an object, got boolean instead.$' ) ;
12
+
7
13
const example = path . join ( common . tmpDir , 'dummy' ) ;
8
14
9
15
common . refreshTmpDir ( ) ;
10
16
11
- assert . doesNotThrow ( function ( ) {
17
+ assert . doesNotThrow ( ( ) => {
12
18
fs . createWriteStream ( example , undefined ) ;
13
19
} ) ;
14
- assert . doesNotThrow ( function ( ) {
20
+
21
+ assert . doesNotThrow ( ( ) => {
15
22
fs . createWriteStream ( example , null ) ;
16
23
} ) ;
17
- assert . doesNotThrow ( function ( ) {
24
+
25
+ assert . doesNotThrow ( ( ) => {
18
26
fs . createWriteStream ( example , 'utf8' ) ;
19
27
} ) ;
20
- assert . doesNotThrow ( function ( ) {
28
+
29
+ assert . doesNotThrow ( ( ) => {
21
30
fs . createWriteStream ( example , { encoding : 'utf8' } ) ;
22
31
} ) ;
23
32
24
- assert . throws ( function ( ) {
33
+ assert . throws ( ( ) => {
25
34
fs . createWriteStream ( example , 123 ) ;
26
- } , / " o p t i o n s " m u s t b e a s t r i n g o r a n o b j e c t / ) ;
27
- assert . throws ( function ( ) {
35
+ } , numberError ) ;
36
+
37
+ assert . throws ( ( ) => {
28
38
fs . createWriteStream ( example , 0 ) ;
29
- } , / " o p t i o n s " m u s t b e a s t r i n g o r a n o b j e c t / ) ;
30
- assert . throws ( function ( ) {
39
+ } , numberError ) ;
40
+
41
+ assert . throws ( ( ) => {
31
42
fs . createWriteStream ( example , true ) ;
32
- } , / " o p t i o n s " m u s t b e a s t r i n g o r a n o b j e c t / ) ;
33
- assert . throws ( function ( ) {
43
+ } , booleanError ) ;
44
+
45
+ assert . throws ( ( ) => {
34
46
fs . createWriteStream ( example , false ) ;
35
- } , / " o p t i o n s " m u s t b e a s t r i n g o r a n o b j e c t / ) ;
47
+ } , booleanError ) ;
0 commit comments