-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: improve code coverage of diagnostics_channel
test: improve code coverage of diagnostics_channel
- Loading branch information
Showing
1 changed file
with
39 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
test/parallel/test-diagnostics-channel-tracing-channel-args-types.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,39 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const dc = require('diagnostics_channel'); | ||
const assert = require('assert'); | ||
|
||
let channel; | ||
|
||
// tracingChannel creating with name | ||
channel = dc.tracingChannel('test'); | ||
assert.match(channel.start.name, /:test:/); | ||
|
||
// tracingChannel creating with channels | ||
channel = dc.tracingChannel({ | ||
start: dc.channel('tracing:test:start'), | ||
end: dc.channel('tracing:test:end'), | ||
asyncStart: dc.channel('tracing:test:asyncStart'), | ||
asyncEnd: dc.channel('tracing:test:asyncEnd'), | ||
error: dc.channel('tracing:test:error'), | ||
}); | ||
|
||
// tracingChannel creating without nameOrChannels must throw TypeError | ||
assert.throws(() => (channel = dc.tracingChannel(0)), { | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
name: 'TypeError', | ||
message: | ||
/The "nameOrChannels" argument must be of type string or an instance of Channel or Object/, | ||
}); | ||
|
||
// tracingChannel creating without instance of Channel must throw error | ||
assert.throws(() => (channel = dc.tracingChannel({ start: '' })), { | ||
code: 'ERR_INVALID_ARG_TYPE', | ||
message: /The "nameOrChannels\.start" property must be an instance of Channel/, | ||
}); | ||
|
||
// tracingChannel creating with empty nameOrChannels must throw error | ||
assert.throws(() => (channel = dc.tracingChannel({})), { | ||
message: /Cannot convert undefined or null to object/, | ||
}); |