@@ -4,72 +4,75 @@ const assert = require('assert');
4
4
const fs = require ( 'fs' ) ;
5
5
6
6
const options = 'test' ;
7
- const unknownEncodingMessage = / ^ E r r o r : U n k n o w n e n c o d i n g : t e s t $ / ;
7
+ const expectedError = common . expectsError ( {
8
+ code : 'ERR_INVALID_OPT_VALUE_ENCODING' ,
9
+ type : TypeError ,
10
+ } , 17 ) ;
8
11
9
12
assert . throws ( ( ) => {
10
13
fs . readFile ( 'path' , options , common . mustNotCall ( ) ) ;
11
- } , unknownEncodingMessage ) ;
14
+ } , expectedError ) ;
12
15
13
16
assert . throws ( ( ) => {
14
17
fs . readFileSync ( 'path' , options ) ;
15
- } , unknownEncodingMessage ) ;
18
+ } , expectedError ) ;
16
19
17
20
assert . throws ( ( ) => {
18
21
fs . readdir ( 'path' , options , common . mustNotCall ( ) ) ;
19
- } , unknownEncodingMessage ) ;
22
+ } , expectedError ) ;
20
23
21
24
assert . throws ( ( ) => {
22
25
fs . readdirSync ( 'path' , options ) ;
23
- } , unknownEncodingMessage ) ;
26
+ } , expectedError ) ;
24
27
25
28
assert . throws ( ( ) => {
26
29
fs . readlink ( 'path' , options , common . mustNotCall ( ) ) ;
27
- } , unknownEncodingMessage ) ;
30
+ } , expectedError ) ;
28
31
29
32
assert . throws ( ( ) => {
30
33
fs . readlinkSync ( 'path' , options ) ;
31
- } , unknownEncodingMessage ) ;
34
+ } , expectedError ) ;
32
35
33
36
assert . throws ( ( ) => {
34
37
fs . writeFile ( 'path' , 'data' , options , common . mustNotCall ( ) ) ;
35
- } , unknownEncodingMessage ) ;
38
+ } , expectedError ) ;
36
39
37
40
assert . throws ( ( ) => {
38
41
fs . writeFileSync ( 'path' , 'data' , options ) ;
39
- } , unknownEncodingMessage ) ;
42
+ } , expectedError ) ;
40
43
41
44
assert . throws ( ( ) => {
42
45
fs . appendFile ( 'path' , 'data' , options , common . mustNotCall ( ) ) ;
43
- } , unknownEncodingMessage ) ;
46
+ } , expectedError ) ;
44
47
45
48
assert . throws ( ( ) => {
46
49
fs . appendFileSync ( 'path' , 'data' , options ) ;
47
- } , unknownEncodingMessage ) ;
50
+ } , expectedError ) ;
48
51
49
52
assert . throws ( ( ) => {
50
53
fs . watch ( 'path' , options , common . mustNotCall ( ) ) ;
51
- } , unknownEncodingMessage ) ;
54
+ } , expectedError ) ;
52
55
53
56
assert . throws ( ( ) => {
54
57
fs . realpath ( 'path' , options , common . mustNotCall ( ) ) ;
55
- } , unknownEncodingMessage ) ;
58
+ } , expectedError ) ;
56
59
57
60
assert . throws ( ( ) => {
58
61
fs . realpathSync ( 'path' , options ) ;
59
- } , unknownEncodingMessage ) ;
62
+ } , expectedError ) ;
60
63
61
64
assert . throws ( ( ) => {
62
65
fs . mkdtemp ( 'path' , options , common . mustNotCall ( ) ) ;
63
- } , unknownEncodingMessage ) ;
66
+ } , expectedError ) ;
64
67
65
68
assert . throws ( ( ) => {
66
69
fs . mkdtempSync ( 'path' , options ) ;
67
- } , unknownEncodingMessage ) ;
70
+ } , expectedError ) ;
68
71
69
72
assert . throws ( ( ) => {
70
73
fs . ReadStream ( 'path' , options ) ;
71
- } , unknownEncodingMessage ) ;
74
+ } , expectedError ) ;
72
75
73
76
assert . throws ( ( ) => {
74
77
fs . WriteStream ( 'path' , options ) ;
75
- } , unknownEncodingMessage ) ;
78
+ } , expectedError ) ;
0 commit comments