0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-fs-constants.js
Livia Medeiros b02cd411c2
fs: runtime deprecate fs.F_OK, fs.R_OK, fs.W_OK, fs.X_OK
PR-URL: https://github.com/nodejs/node/pull/49686
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2024-11-14 23:34:02 +00:00

28 lines
978 B
JavaScript

'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);