Skip to content

Commit 8ac6a70

Browse files
hiroppyitaloacasas
authored andcommitted
test: add fs-assert-encoding's test
Check the error of `assertEncoding`. Confirmed in every place being used.(a place where `getoptions` is used) assetEncoding: https://github.com/nodejs/node/blob/521767c88605cb6481ea98f396924e55f9dd22f4/lib/internal/fs.js#L18 PR-URL: #10913 Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent c5210b2 commit 8ac6a70

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
'use strict';
2+
require('../common');
3+
const assert = require('assert');
4+
const fs = require('fs');
5+
6+
const options = 'test';
7+
const noop = () => {};
8+
const unknownEncodingMessage = /^Error: Unknown encoding: test$/;
9+
10+
assert.throws(() => {
11+
fs.readFile('path', options, noop);
12+
}, unknownEncodingMessage);
13+
14+
assert.throws(() => {
15+
fs.readFileSync('path', options);
16+
}, unknownEncodingMessage);
17+
18+
assert.throws(() => {
19+
fs.readdir('path', options, noop);
20+
}, unknownEncodingMessage);
21+
22+
assert.throws(() => {
23+
fs.readdirSync('path', options);
24+
}, unknownEncodingMessage);
25+
26+
assert.throws(() => {
27+
fs.readlink('path', options, noop);
28+
}, unknownEncodingMessage);
29+
30+
assert.throws(() => {
31+
fs.readlinkSync('path', options);
32+
}, unknownEncodingMessage);
33+
34+
assert.throws(() => {
35+
fs.writeFile('path', 'data', options, noop);
36+
}, unknownEncodingMessage);
37+
38+
assert.throws(() => {
39+
fs.writeFileSync('path', 'data', options);
40+
}, unknownEncodingMessage);
41+
42+
assert.throws(() => {
43+
fs.appendFile('path', 'data', options, noop);
44+
}, unknownEncodingMessage);
45+
46+
assert.throws(() => {
47+
fs.appendFileSync('path', 'data', options);
48+
}, unknownEncodingMessage);
49+
50+
assert.throws(() => {
51+
fs.watch('path', options, noop);
52+
}, unknownEncodingMessage);
53+
54+
assert.throws(() => {
55+
fs.realpath('path', options, noop);
56+
}, unknownEncodingMessage);
57+
58+
assert.throws(() => {
59+
fs.realpathSync('path', options);
60+
}, unknownEncodingMessage);
61+
62+
assert.throws(() => {
63+
fs.mkdtemp('path', options, noop);
64+
}, unknownEncodingMessage);
65+
66+
assert.throws(() => {
67+
fs.mkdtempSync('path', options);
68+
}, unknownEncodingMessage);
69+
70+
assert.throws(() => {
71+
fs.ReadStream('path', options);
72+
}, unknownEncodingMessage);
73+
74+
assert.throws(() => {
75+
fs.WriteStream('path', options);
76+
}, unknownEncodingMessage);

0 commit comments

Comments
 (0)