• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2const common = require('../common');
3const assert = require('node:assert');
4const fs = require('node:fs');
5const path = require('node:path');
6const tmpdir = require('../common/tmpdir');
7
8const testPath = path.join(tmpdir.path, 'assert-encoding-error');
9const options = 'test';
10const expectedError = {
11  code: 'ERR_INVALID_ARG_VALUE',
12  name: 'TypeError',
13};
14
15assert.throws(() => {
16  fs.readFile(testPath, options, common.mustNotCall());
17}, expectedError);
18
19assert.throws(() => {
20  fs.readFileSync(testPath, options);
21}, expectedError);
22
23assert.throws(() => {
24  fs.readdir(testPath, options, common.mustNotCall());
25}, expectedError);
26
27assert.throws(() => {
28  fs.readdirSync(testPath, options);
29}, expectedError);
30
31assert.throws(() => {
32  fs.readlink(testPath, options, common.mustNotCall());
33}, expectedError);
34
35assert.throws(() => {
36  fs.readlinkSync(testPath, options);
37}, expectedError);
38
39assert.throws(() => {
40  fs.writeFile(testPath, 'data', options, common.mustNotCall());
41}, expectedError);
42
43assert.throws(() => {
44  fs.writeFileSync(testPath, 'data', options);
45}, expectedError);
46
47assert.throws(() => {
48  fs.appendFile(testPath, 'data', options, common.mustNotCall());
49}, expectedError);
50
51assert.throws(() => {
52  fs.appendFileSync(testPath, 'data', options);
53}, expectedError);
54
55assert.throws(() => {
56  fs.watch(testPath, options, common.mustNotCall());
57}, expectedError);
58
59assert.throws(() => {
60  fs.realpath(testPath, options, common.mustNotCall());
61}, expectedError);
62
63assert.throws(() => {
64  fs.realpathSync(testPath, options);
65}, expectedError);
66
67assert.throws(() => {
68  fs.mkdtemp(testPath, options, common.mustNotCall());
69}, expectedError);
70
71assert.throws(() => {
72  fs.mkdtempSync(testPath, options);
73}, expectedError);
74
75assert.throws(() => {
76  fs.ReadStream(testPath, options);
77}, expectedError);
78
79assert.throws(() => {
80  fs.WriteStream(testPath, options);
81}, expectedError);
82