Skip to content

Commit 10b0432

Browse files
authored
test: improve test coverage of internal/worker/io
PR-URL: #41511 Refs: https://coverage.nodejs.org/coverage-74b9baa4265a8f0d/lib/internal/worker/io.js.html#L415 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]>
1 parent 716aefd commit 10b0432

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
require('../common');
4+
const { BroadcastChannel } = require('worker_threads');
5+
const { inspect } = require('util');
6+
const assert = require('assert');
7+
8+
// This test checks BroadcastChannel custom inspect outputs
9+
10+
{
11+
const bc = new BroadcastChannel('name');
12+
assert.throws(() => bc[inspect.custom].call(), {
13+
code: 'ERR_INVALID_THIS',
14+
});
15+
bc.close();
16+
}
17+
18+
{
19+
const bc = new BroadcastChannel('name');
20+
assert.strictEqual(inspect(bc, { depth: -1 }), 'BroadcastChannel');
21+
bc.close();
22+
}
23+
24+
{
25+
const bc = new BroadcastChannel('name');
26+
assert.strictEqual(
27+
inspect(bc),
28+
"BroadcastChannel { name: 'name', active: true }"
29+
);
30+
bc.close();
31+
}
32+
33+
{
34+
const bc = new BroadcastChannel('name');
35+
assert.strictEqual(
36+
inspect(bc, { depth: null }),
37+
"BroadcastChannel { name: 'name', active: true }"
38+
);
39+
bc.close();
40+
}

0 commit comments

Comments
 (0)