0
0
mirror of https://github.com/nodejs/node.git synced 2024-11-21 21:19:50 +01:00
nodejs/test/parallel/test-domain-ee.js
Gang Chen 22792c8632
domain: pass opts to EventEmitter.init
PR-URL: https://github.com/nodejs/node/pull/41414
Fixes: https://github.com/nodejs/node/issues/41391
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
2022-01-19 11:26:38 +00:00

29 lines
818 B
JavaScript

'use strict';
const common = require('../common');
const assert = require('assert');
const domain = require('domain');
const EventEmitter = require('events');
const d = new domain.Domain();
const e = new EventEmitter();
d.on('error', common.mustCall((err) => {
assert.strictEqual(err.message, 'foobar');
assert.strictEqual(err.domain, d);
assert.strictEqual(err.domainEmitter, e);
assert.strictEqual(err.domainBound, undefined);
assert.strictEqual(err.domainThrown, false);
}));
d.add(e);
e.emit('error', new Error('foobar'));
{
// Ensure initial params pass to origin `EventEmitter.init` function
const e = new EventEmitter({ captureRejections: true });
const kCapture = Object.getOwnPropertySymbols(e)
.find((it) => it.description === 'kCapture');
assert.strictEqual(e[kCapture], true);
}