• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1'use strict';
2
3const common = require('../common');
4const dc = require('diagnostics_channel');
5const assert = require('assert');
6
7const input = {
8  foo: 'bar'
9};
10
11const symbol = Symbol('test');
12
13// Individual channel objects can be created to avoid future lookups
14const channel = dc.channel(symbol);
15
16// Expect two successful publishes later
17channel.subscribe(common.mustCall((message, name) => {
18  assert.strictEqual(name, symbol);
19  assert.deepStrictEqual(message, input);
20}));
21
22channel.publish(input);
23
24{
25  assert.throws(() => {
26    dc.channel(null);
27  }, /ERR_INVALID_ARG_TYPE/);
28}
29