Skip to content

Commit 1d3ef11

Browse files
kuriyoshdanielleadams
authored andcommitted
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 <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
1 parent 39f52e1 commit 1d3ef11

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
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+
constassert=require('assert');
7+
8+
// This test checks BroadcastChannel custom inspect outputs
9+
10+
{
11+
constbc=newBroadcastChannel('name');
12+
assert.throws(()=>bc[inspect.custom].call(),{
13+
code: 'ERR_INVALID_THIS',
14+
});
15+
bc.close();
16+
}
17+
18+
{
19+
constbc=newBroadcastChannel('name');
20+
assert.strictEqual(inspect(bc,{depth: -1}),'BroadcastChannel');
21+
bc.close();
22+
}
23+
24+
{
25+
constbc=newBroadcastChannel('name');
26+
assert.strictEqual(
27+
inspect(bc),
28+
"BroadcastChannel { name: 'name', active: true }"
29+
);
30+
bc.close();
31+
}
32+
33+
{
34+
constbc=newBroadcastChannel('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)