(binding)
| 5 | module.exports = require('../common').runTest(test); |
| 6 | |
| 7 | function test (binding) { |
| 8 | function testSetProperty (nativeSetProperty, key = 'test') { |
| 9 | const obj = {}; |
| 10 | assert.strictEqual(nativeSetProperty(obj, key, 1), true); |
| 11 | assert.strictEqual(obj[key], 1); |
| 12 | } |
| 13 | |
| 14 | function testShouldThrowErrorIfKeyIsInvalid (nativeSetProperty) { |
| 15 | assert.throws(() => { |
| 16 | nativeSetProperty(undefined, 'test', 1); |
| 17 | }, /Cannot convert undefined or null to object/); |
| 18 | } |
| 19 | |
| 20 | testSetProperty(binding.object.setPropertyWithNapiValue); |
| 21 | testSetProperty(binding.object.setPropertyWithNapiWrapperValue); |
| 22 | testSetProperty(binding.object.setPropertyWithCStyleString); |
| 23 | testSetProperty(binding.object.setPropertyWithCppStyleString); |
| 24 | testSetProperty(binding.object.setPropertyWithUint32, 12); |
| 25 | |
| 26 | testShouldThrowErrorIfKeyIsInvalid(binding.object.setPropertyWithNapiValue); |
| 27 | testShouldThrowErrorIfKeyIsInvalid(binding.object.setPropertyWithNapiWrapperValue); |
| 28 | testShouldThrowErrorIfKeyIsInvalid(binding.object.setPropertyWithCStyleString); |
| 29 | testShouldThrowErrorIfKeyIsInvalid(binding.object.setPropertyWithCppStyleString); |
| 30 | } |
nothing calls this directly
no test coverage detected