forked from nodejs/node
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest-fs-constants.js
More file actions
27 lines (22 loc) · 978 Bytes
/
test-fs-constants.js
File metadata and controls
27 lines (22 loc) · 978 Bytes
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
'use strict';
const { expectWarning } = require('../common');
const fs = require('fs');
const assert = require('assert');
// Check if the two constants accepted by chmod() on Windows are defined.
assert.notStrictEqual(fs.constants.S_IRUSR, undefined);
assert.notStrictEqual(fs.constants.S_IWUSR, undefined);
// Check for runtime deprecation warning, there should be no setter
const { F_OK, R_OK, W_OK, X_OK } = fs.constants;
assert.throws(() => { fs.F_OK = 'overwritten'; }, { name: 'TypeError' });
assert.throws(() => { fs.R_OK = 'overwritten'; }, { name: 'TypeError' });
assert.throws(() => { fs.W_OK = 'overwritten'; }, { name: 'TypeError' });
assert.throws(() => { fs.X_OK = 'overwritten'; }, { name: 'TypeError' });
expectWarning(
'DeprecationWarning',
'fs.F_OK is deprecated, use fs.constants.F_OK instead',
'DEP0176'
);
assert.strictEqual(fs.F_OK, F_OK);
assert.strictEqual(fs.R_OK, R_OK);
assert.strictEqual(fs.W_OK, W_OK);
assert.strictEqual(fs.X_OK, X_OK);