@@ -4,32 +4,44 @@ const assert = require('assert');
44const fs = require ( 'fs' ) ;
55const path = require ( 'path' ) ;
66
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+
713const example = path . join ( common . tmpDir , 'dummy' ) ;
814
915common . refreshTmpDir ( ) ;
1016
11- assert . doesNotThrow ( function ( ) {
17+ assert . doesNotThrow ( ( ) => {
1218 fs . createWriteStream ( example , undefined ) ;
1319} ) ;
14- assert . doesNotThrow ( function ( ) {
20+
21+ assert . doesNotThrow ( ( ) => {
1522 fs . createWriteStream ( example , null ) ;
1623} ) ;
17- assert . doesNotThrow ( function ( ) {
24+
25+ assert . doesNotThrow ( ( ) => {
1826 fs . createWriteStream ( example , 'utf8' ) ;
1927} ) ;
20- assert . doesNotThrow ( function ( ) {
28+
29+ assert . doesNotThrow ( ( ) => {
2130 fs . createWriteStream ( example , { encoding : 'utf8' } ) ;
2231} ) ;
2332
24- assert . throws ( function ( ) {
33+ assert . throws ( ( ) => {
2534 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 ( ( ) => {
2838 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 ( ( ) => {
3142 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 ( ( ) => {
3446 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