★ wanayoo — archive 1999 https://github.com/nodejs/node/commit/0a104ef33cNouvelle recherche | Portail wanayoo
Skip to content
Permalink
Browse files

test: test add and remove for lib/domain

Testing some of the more specific cases of using domain.add and
domain.remove. For example, calling domain.add twice with same event
emmiter and actually removing an event emitter from the domain.

PR-URL: #24163
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information...
dodev authored and BridgeAR committed Nov 6, 2018
1 parent 1c8b4d7 commit 0a104ef33cf4ddfaf20dd18adf81d446e6891fd5
Showing with 26 additions and 0 deletions.
  1. +26 −0 test/parallel/test-domain-add-remove.js
@@ -0,0 +1,26 @@
'use strict';

require('../common');
const assert = require('assert');
const domain = require('domain');
const EventEmitter = require('events');

const d = new domain.Domain();
const e = new EventEmitter();
const e2 = new EventEmitter();

d.add(e);
assert.strictEqual(e.domain, d);

// Adding the same event to a domain should not change the member count
let previousMemberCount = d.members.length;
d.add(e);
assert.strictEqual(previousMemberCount, d.members.length);

d.add(e2);
assert.strictEqual(e2.domain, d);

previousMemberCount = d.members.length;
d.remove(e2);
assert.notStrictEqual(e2.domain, d);
assert.strictEqual(previousMemberCount - 1, d.members.length);

0 comments on commit 0a104ef

Please sign in to comment.
You can’t perform that action at this time.