0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-constants.js
Juan José Arboleda 7534477786
test: replace flag expose_internals to expose-internals
PR-URL: https://github.com/nodejs/node/pull/32542
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Rich Trott <rtrott@gmail.com>
2020-04-02 18:28:23 +02:00

31 lines
859 B
JavaScript

// Flags: --expose-internals
'use strict';
require('../common');
const { internalBinding } = require('internal/test/binding');
const binding = internalBinding('constants');
const constants = require('constants');
const assert = require('assert');
assert.ok(binding);
assert.ok(binding.os);
assert.ok(binding.os.signals);
assert.ok(binding.os.errno);
assert.ok(binding.fs);
assert.ok(binding.crypto);
['os', 'fs', 'crypto'].forEach((l) => {
Object.keys(binding[l]).forEach((k) => {
if (typeof binding[l][k] === 'object') { // errno and signals
Object.keys(binding[l][k]).forEach((j) => {
assert.strictEqual(binding[l][k][j], constants[j]);
});
}
if (l !== 'os') { // Top level os constant isn't currently copied
assert.strictEqual(binding[l][k], constants[k]);
}
});
});
assert.ok(Object.isFrozen(constants));