mirror of
https://github.com/nodejs/node.git
synced 2025-04-28 13:40:37 +00:00

1. test subscribe with invalid args https://coverage.nodejs.org/coverage-21f2e8859dfbf09f/lib/diagnostics_channel.js.html#L27 2. test create channel with invalid args https://coverage.nodejs.org/coverage-21f2e8859dfbf09f/lib/diagnostics_channel.js.html#L98 PR-URL: https://github.com/nodejs/node/pull/36602 Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michael Dawson <midawson@redhat.com> Reviewed-By: Pooja D P <Pooja.D.P@ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yash Ladha <yash@yashladha.in>
29 lines
586 B
JavaScript
29 lines
586 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
const dc = require('diagnostics_channel');
|
|
const assert = require('assert');
|
|
|
|
const input = {
|
|
foo: 'bar'
|
|
};
|
|
|
|
const symbol = Symbol('test');
|
|
|
|
// Individual channel objects can be created to avoid future lookups
|
|
const channel = dc.channel(symbol);
|
|
|
|
// Expect two successful publishes later
|
|
channel.subscribe(common.mustCall((message, name) => {
|
|
assert.strictEqual(name, symbol);
|
|
assert.deepStrictEqual(message, input);
|
|
}));
|
|
|
|
channel.publish(input);
|
|
|
|
{
|
|
assert.throws(() => {
|
|
dc.channel(null);
|
|
}, /ERR_INVALID_ARG_TYPE/);
|
|
}
|