• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../../common');
4const assert = require('assert');
5const domain = require('domain');
6const binding = require(`./build/${common.buildType}/binding`);
7
8function makeCallback(object, cb) {
9  binding.makeCallback(object, () => setImmediate(cb));
10}
11
12let latestWarning = null;
13process.on('warning', (warning) => {
14  latestWarning = warning;
15});
16
17const d = domain.create();
18
19// When domain is disabled, no warning will be emitted
20makeCallback({ domain: d }, common.mustCall(() => {
21  assert.strictEqual(latestWarning, null);
22
23  d.run(common.mustCall(() => {
24    // No warning will be emitted when no domain property is applied
25    makeCallback({}, common.mustCall(() => {
26      assert.strictEqual(latestWarning, null);
27
28      // Warning is emitted when domain property is used and domain is enabled
29      makeCallback({ domain: d }, common.mustCall(() => {
30        assert.strictEqual(latestWarning.name, 'DeprecationWarning');
31        assert.strictEqual(latestWarning.code, 'DEP0097');
32      }));
33    }));
34  }));
35}));
36