-
-
Notifications
You must be signed in to change notification settings - Fork 35.4k
Expand file tree
/
Copy pathtest-diagnostics-channel-meta-channels.js
More file actions
35 lines (28 loc) · 1.41 KB
/
test-diagnostics-channel-meta-channels.js
File metadata and controls
35 lines (28 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
const common = require('../common');
const dc = require('diagnostics_channel');
const assert = require('assert');
const testedChannel = dc.channel('test');
const testedSubscription = () => {};
const testedData = { foo: 'bar' };
// should publish on meta channel for subscribe() on both inactive and active prototype
dc.subscribe('diagnostics_channel.subscribe', common.mustCall(({ channel, subscription }) => {
assert.strictEqual(channel, testedChannel);
assert.strictEqual(subscription, testedSubscription);
}, 2)); // called twice
testedChannel.subscribe(testedSubscription); // inactive prototype
testedChannel.subscribe(testedSubscription); // active prototype
// should publish on meta channel for publish()
dc.subscribe('diagnostics_channel.publish', common.mustCall(({ channel, data }) => {
assert.strictEqual(channel, testedChannel);
assert.strictEqual(data, testedData);
}));
testedChannel.publish(testedData);
// should publish on meta channel for unsubscribe() on both inactive and active prototype
dc.subscribe('diagnostics_channel.unsubscribe', common.mustCall(({ channel, subscription }) => {
assert.strictEqual(channel, testedChannel);
assert.strictEqual(subscription, testedSubscription);
}, 2)); // called twice
testedChannel.unsubscribe(testedSubscription); // active prototype
testedChannel.unsubscribe(testedSubscription); // inactive prototype
// TODO: should it publish on inactive channels ?