Skip to content

Commit

Permalink
test: improve internal/worker/io.js coverage
Browse files Browse the repository at this point in the history
PR-URL: #42387
Refs: https://coverage.nodejs.org/coverage-6d3920d579a3dc3a/lib/internal/worker/io.js.html#L485
Reviewed-By: Darshan Sen <raisinten@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Akhil Marsonya <akhil.marsonya27@gmail.com>
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Debadree Chatterjee <debadree333@gmail.com>
Reviewed-By: Michael Dawson <midawson@redhat.com>
  • Loading branch information
kuriyosh authored Jul 31, 2023
1 parent 7a33f2b commit 1dcfc65
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions test/parallel/test-worker-broadcastchannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const {
receiveMessageOnPort
} = require('worker_threads');
const assert = require('assert');
const { inspect } = require('util');

assert.throws(() => new BroadcastChannel(Symbol('test')), {
message: /Cannot convert a Symbol value to a string/
Expand Down Expand Up @@ -168,3 +169,17 @@ assert.throws(() => new BroadcastChannel(), {
});
});
}

{
const bc = new BroadcastChannel('channel5');
assert.strictEqual(
inspect(bc.ref()),
"BroadcastChannel { name: 'channel5', active: true }"
);

bc.close();
assert.strictEqual(
inspect(bc.ref()),
"BroadcastChannel { name: 'channel5', active: false }"
);
}

0 comments on commit 1dcfc65

Please sign in to comment.