-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
- Loading branch information
Showing
2 changed files
with
89 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
52 changes: 52 additions & 0 deletions
52
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,52 @@ | ||
'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); | ||
} | ||
|
||