summaryrefslogtreecommitdiff
path: root/test/parallel/test-fs-assert-encoding-error.js
blob: 7f32c06ea89419babfa6852085efd84422d63d3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'use strict';
const common = require('../common');
const assert = require('node:assert');
const fs = require('node:fs');
const path = require('node:path');
const tmpdir = require('../common/tmpdir');

const testPath = path.join(tmpdir.path, 'assert-encoding-error');
const options = 'test';
const expectedError = {
  code: 'ERR_INVALID_ARG_VALUE',
  name: 'TypeError',
};

assert.throws(() => {
  fs.readFile(testPath, options, common.mustNotCall());
}, expectedError);

assert.throws(() => {
  fs.readFileSync(testPath, options);
}, expectedError);

assert.throws(() => {
  fs.readdir(testPath, options, common.mustNotCall());
}, expectedError);

assert.throws(() => {
  fs.readdirSync(testPath, options);
}, expectedError);

assert.throws(() => {
  fs.readlink(testPath, options, common.mustNotCall());
}, expectedError);

assert.throws(() => {
  fs.readlinkSync(testPath, options);
}, expectedError);

assert.throws(() => {
  fs.writeFile(testPath, 'data', options, common.mustNotCall());
}, expectedError);

assert.throws(() => {
  fs.writeFileSync(testPath, 'data', options);
}, expectedError);

assert.throws(() => {
  fs.appendFile(testPath, 'data', options, common.mustNotCall());
}, expectedError);

assert.throws(() => {
  fs.appendFileSync(testPath, 'data', options);
}, expectedError);

assert.throws(() => {
  fs.watch(testPath, options, common.mustNotCall());
}, expectedError);

assert.throws(() => {
  fs.realpath(testPath, options, common.mustNotCall());
}, expectedError);

assert.throws(() => {
  fs.realpathSync(testPath, options);
}, expectedError);

assert.throws(() => {
  fs.mkdtemp(testPath, options, common.mustNotCall());
}, expectedError);

assert.throws(() => {
  fs.mkdtempSync(testPath, options);
}, expectedError);

assert.throws(() => {
  fs.ReadStream(testPath, options);
}, expectedError);

assert.throws(() => {
  fs.WriteStream(testPath, options);
}, expectedError);