mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
36e44f1230
follow up work for https://github.com/nodejs/node/pull/51915 PR-URL: https://github.com/nodejs/node/pull/52908 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com>
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const dc = require('diagnostics_channel');
|
|
const assert = require('assert');
|
|
|
|
const handler = common.mustNotCall();
|
|
|
|
{
|
|
const handlers = {
|
|
start: common.mustNotCall()
|
|
};
|
|
|
|
const channel = dc.tracingChannel('test');
|
|
|
|
assert.strictEqual(channel.hasSubscribers, false);
|
|
|
|
channel.subscribe(handlers);
|
|
assert.strictEqual(channel.hasSubscribers, true);
|
|
|
|
channel.unsubscribe(handlers);
|
|
assert.strictEqual(channel.hasSubscribers, false);
|
|
|
|
channel.start.subscribe(handler);
|
|
assert.strictEqual(channel.hasSubscribers, true);
|
|
|
|
channel.start.unsubscribe(handler);
|
|
assert.strictEqual(channel.hasSubscribers, false);
|
|
}
|
|
|
|
{
|
|
const handlers = {
|
|
asyncEnd: common.mustNotCall()
|
|
};
|
|
|
|
const channel = dc.tracingChannel('test');
|
|
|
|
assert.strictEqual(channel.hasSubscribers, false);
|
|
|
|
channel.subscribe(handlers);
|
|
assert.strictEqual(channel.hasSubscribers, true);
|
|
|
|
channel.unsubscribe(handlers);
|
|
assert.strictEqual(channel.hasSubscribers, false);
|
|
|
|
channel.asyncEnd.subscribe(handler);
|
|
assert.strictEqual(channel.hasSubscribers, true);
|
|
|
|
channel.asyncEnd.unsubscribe(handler);
|
|
assert.strictEqual(channel.hasSubscribers, false);
|
|
}
|