MCPcopy Create free account
hub / github.com/nodejs/node / setPropertyAndAssert

Function setPropertyAndAssert

test/parallel/test-vm-global-get-own.js:78–96  ·  view source on GitHub ↗
(data, property, viaDefine, value)

Source from the content-addressed store, hash-verified

76
77// Set the property on data and assert it worked
78function setPropertyAndAssert(data, property, viaDefine, value) {
79 if (viaDefine) {
80 Object.defineProperty(data, property, {
81 enumerable: true,
82 writable: true,
83 value: value,
84 configurable: true,
85 });
86 } else {
87 data[property] = value;
88 }
89 assert.strictEqual(data[property], value);
90 assert.ok(property in data);
91 if (typeof property === 'string') {
92 assert.ok(Object.getOwnPropertyNames(data).includes(property));
93 } else {
94 assert.ok(Object.getOwnPropertySymbols(data).includes(property));
95 }
96}
97
98// Delete the property from data and assert it worked
99function deletePropertyAndAssert(data, property) {

Callers 1

runAssertionsFunction · 0.85

Calls 3

includesMethod · 0.80
definePropertyMethod · 0.45
okMethod · 0.45

Tested by

no test coverage detected