-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
doc, test: tracing channel hasSubscribers getter
follow up work for #51915 PR-URL: #52908 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com> Reviewed-By: James M Snell <jasnell@gmail.com>
- Loading branch information
1 parent
5eea419
commit f336e61
Showing
2 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
test/parallel/test-diagnostics-channel-tracing-channel-has-subscribers.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
'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); | ||
} |