mirror of
https://github.com/zebrajr/node.git
synced 2025-12-06 12:20:27 +01:00
Convert all anonymous callback functions in `test/addons/**/*.js` to use arrow functions, except for those in `test/addons/make-callback/test.js` (which reference `this`) `writing-tests.md` states to use arrow functions when appropriate. PR-URL: https://github.com/nodejs/node/pull/30131 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
36 lines
1.0 KiB
JavaScript
36 lines
1.0 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../../common');
|
|
const assert = require('assert');
|
|
const domain = require('domain');
|
|
const binding = require(`./build/${common.buildType}/binding`);
|
|
|
|
function makeCallback(object, cb) {
|
|
binding.makeCallback(object, () => setImmediate(cb));
|
|
}
|
|
|
|
let latestWarning = null;
|
|
process.on('warning', (warning) => {
|
|
latestWarning = warning;
|
|
});
|
|
|
|
const d = domain.create();
|
|
|
|
// When domain is disabled, no warning will be emitted
|
|
makeCallback({ domain: d }, common.mustCall(() => {
|
|
assert.strictEqual(latestWarning, null);
|
|
|
|
d.run(common.mustCall(() => {
|
|
// No warning will be emitted when no domain property is applied
|
|
makeCallback({}, common.mustCall(() => {
|
|
assert.strictEqual(latestWarning, null);
|
|
|
|
// Warning is emitted when domain property is used and domain is enabled
|
|
makeCallback({ domain: d }, common.mustCall(() => {
|
|
assert.strictEqual(latestWarning.name, 'DeprecationWarning');
|
|
assert.strictEqual(latestWarning.code, 'DEP0097');
|
|
}));
|
|
}));
|
|
}));
|
|
}));
|