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

Function testDeleteProperty

test/object/delete_property.js:8–18  ·  view source on GitHub ↗
(nativeDeleteProperty)

Source from the content-addressed store, hash-verified

6
7function test (binding) {
8 function testDeleteProperty (nativeDeleteProperty) {
9 const obj = { one: 1, two: 2 };
10 Object.defineProperty(obj, 'three', { configurable: false, value: 3 });
11 assert.strictEqual(nativeDeleteProperty(obj, 'one'), true);
12 assert.strictEqual(nativeDeleteProperty(obj, 'missing'), true);
13
14 /* Returns true for all cases except when the property is an own non-
15 configurable property, in which case, false is returned in non-strict mode. */
16 assert.strictEqual(nativeDeleteProperty(obj, 'three'), false);
17 assert.deepStrictEqual(obj, { two: 2 });
18 }
19
20 function testShouldThrowErrorIfKeyIsInvalid (nativeDeleteProperty) {
21 assert.throws(() => {

Callers 1

testFunction · 0.85

Calls

no outgoing calls

Tested by 1

testFunction · 0.68