|
2 | 2 |
|
3 | 3 | const common = require('../common'); |
4 | 4 | const assert = require('assert'); |
5 | | -const util = require('util'); |
6 | 5 | const fs = require('fs'); |
7 | 6 | const { promises } = fs; |
8 | 7 | const f = __filename; |
@@ -38,18 +37,22 @@ assert.throws(() => fs.lchmod(f, {}), { code: 'ERR_INVALID_CALLBACK' }); |
38 | 37 | }); |
39 | 38 |
|
40 | 39 | // Check mode |
41 | | -[false, null, undefined, {}, [], '', '123x'].forEach((input) => { |
| 40 | +[false, null, {}, []].forEach((input) => { |
42 | 41 | const errObj = { |
43 | | - code: 'ERR_INVALID_ARG_VALUE', |
44 | | - name: 'TypeError', |
45 | | - message: 'The argument \'mode\' must be a 32-bit unsigned integer or an ' + |
46 | | - `octal string. Received ${util.inspect(input)}` |
| 42 | + code: 'ERR_INVALID_ARG_TYPE', |
47 | 43 | }; |
48 | 44 |
|
49 | 45 | assert.rejects(promises.lchmod(f, input, () => {}), errObj); |
50 | 46 | assert.throws(() => fs.lchmodSync(f, input), errObj); |
51 | 47 | }); |
52 | 48 |
|
| 49 | +assert.throws(() => fs.lchmod(f, '123x', common.mustNotCall()), { |
| 50 | + code: 'ERR_INVALID_ARG_VALUE' |
| 51 | +}); |
| 52 | +assert.throws(() => fs.lchmodSync(f, '123x'), { |
| 53 | + code: 'ERR_INVALID_ARG_VALUE' |
| 54 | +}); |
| 55 | + |
53 | 56 | [-1, 2 ** 32].forEach((input) => { |
54 | 57 | const errObj = { |
55 | 58 | code: 'ERR_OUT_OF_RANGE', |
|
0 commit comments