node/test/js-native-api/3_callbacks/test.js
Gabriel Schulhof 3f025cb5d0 test: give js-native-api tests consistent names
The convention for js-native-api/<test_name>:
  * <test_name>.c or <test_name>.cc has the entry point
  * The name of the target is <test_name>

PR-URL: https://github.com/nodejs/node/pull/38692
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2021-05-19 16:43:19 -04:00

23 lines
488 B
JavaScript

'use strict';
const common = require('../../common');
const assert = require('assert');
const addon = require(`./build/${common.buildType}/3_callbacks`);
addon.RunCallback(function(msg) {
assert.strictEqual(msg, 'hello world');
});
function testRecv(desiredRecv) {
addon.RunCallbackWithRecv(function() {
assert.strictEqual(this, desiredRecv);
}, desiredRecv);
}
testRecv(undefined);
testRecv(null);
testRecv(5);
testRecv(true);
testRecv('Hello');
testRecv([]);
testRecv({});