|
| 1 | +'use strict'; |
| 2 | + |
| 3 | +const test = require('tape'); |
| 4 | +const common = require('./common.js'); |
| 5 | +const dc = require('../dc-polyfill.js'); |
| 6 | + |
| 7 | +test('test-diagnostics-channel-tracing-has-subscribers', (t) => { |
| 8 | + t.plan(10); |
| 9 | + |
| 10 | + const handler = common.mustNotCall(); |
| 11 | + |
| 12 | + { |
| 13 | + const handlers = { |
| 14 | + start: common.mustNotCall() |
| 15 | + }; |
| 16 | + |
| 17 | + const channel = dc.tracingChannel('test'); |
| 18 | + |
| 19 | + t.strictEqual(channel.hasSubscribers, false); |
| 20 | + |
| 21 | + channel.subscribe(handlers); |
| 22 | + t.strictEqual(channel.hasSubscribers, true); |
| 23 | + |
| 24 | + channel.unsubscribe(handlers); |
| 25 | + t.strictEqual(channel.hasSubscribers, false); |
| 26 | + |
| 27 | + channel.start.subscribe(handler); |
| 28 | + t.strictEqual(channel.hasSubscribers, true); |
| 29 | + |
| 30 | + channel.start.unsubscribe(handler); |
| 31 | + t.strictEqual(channel.hasSubscribers, false); |
| 32 | + } |
| 33 | + |
| 34 | + { |
| 35 | + const handlers = { |
| 36 | + asyncEnd: common.mustNotCall() |
| 37 | + }; |
| 38 | + |
| 39 | + const channel = dc.tracingChannel('test'); |
| 40 | + |
| 41 | + t.strictEqual(channel.hasSubscribers, false); |
| 42 | + |
| 43 | + channel.subscribe(handlers); |
| 44 | + t.strictEqual(channel.hasSubscribers, true); |
| 45 | + |
| 46 | + channel.unsubscribe(handlers); |
| 47 | + t.strictEqual(channel.hasSubscribers, false); |
| 48 | + |
| 49 | + channel.asyncEnd.subscribe(handler); |
| 50 | + t.strictEqual(channel.hasSubscribers, true); |
| 51 | + |
| 52 | + channel.asyncEnd.unsubscribe(handler); |
| 53 | + t.strictEqual(channel.hasSubscribers, false); |
| 54 | + } |
| 55 | +}); |
0 commit comments