MCPcopy Create free account
hub / github.com/nodejs/node-addon-api / test

Function test

test/object/object_deprecated.js:7–42  ·  view source on GitHub ↗
(binding)

Source from the content-addressed store, hash-verified

5module.exports = require('../common').runTest(test);
6
7function test (binding) {
8 if (!('object_deprecated' in binding)) {
9 return;
10 }
11
12 function assertPropertyIsNot (obj, key, attribute) {
13 const propDesc = Object.getOwnPropertyDescriptor(obj, key);
14 assert.ok(propDesc);
15 assert.ok(!propDesc[attribute]);
16 }
17
18 function testDefineProperties (nameType) {
19 const obj = {};
20 binding.object.defineProperties(obj, nameType);
21
22 assertPropertyIsNot(obj, 'readonlyAccessor', 'enumerable');
23 assertPropertyIsNot(obj, 'readonlyAccessor', 'configurable');
24 assert.strictEqual(obj.readonlyAccessor, true);
25
26 assertPropertyIsNot(obj, 'readwriteAccessor', 'enumerable');
27 assertPropertyIsNot(obj, 'readwriteAccessor', 'configurable');
28 obj.readwriteAccessor = false;
29 assert.strictEqual(obj.readwriteAccessor, false);
30 obj.readwriteAccessor = true;
31 assert.strictEqual(obj.readwriteAccessor, true);
32
33 assertPropertyIsNot(obj, 'function', 'writable');
34 assertPropertyIsNot(obj, 'function', 'enumerable');
35 assertPropertyIsNot(obj, 'function', 'configurable');
36 assert.strictEqual(obj.function(), true);
37 }
38
39 testDefineProperties('literal');
40 testDefineProperties('string');
41 testDefineProperties('value');
42}

Callers

nothing calls this directly

Calls 1

testDefinePropertiesFunction · 0.70

Tested by

no test coverage detected