summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoshiki Kurihara <yosyos0306@gmail.com>2022-01-21 07:41:45 +0900
committerGitHub <noreply@github.com>2022-01-20 22:41:45 +0000
commit10b043287c3fe96f677e95a0229c520a57105316 (patch)
tree1eb53afff4666647f501259f985fb3fbad7891e3
parent716aefde411767d4653d4314e9c55ff7302301f4 (diff)
downloadnode-new-10b043287c3fe96f677e95a0229c520a57105316.tar.gz
test: improve test coverage of internal/worker/io
PR-URL: https://github.com/nodejs/node/pull/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>
-rw-r--r--test/parallel/test-broadcastchannel-custom-inspect.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/parallel/test-broadcastchannel-custom-inspect.js b/test/parallel/test-broadcastchannel-custom-inspect.js
new file mode 100644
index 0000000000..409501cb16
--- /dev/null
+++ b/test/parallel/test-broadcastchannel-custom-inspect.js
@@ -0,0 +1,40 @@
+'use strict';
+
+require('../common');
+const { BroadcastChannel } = require('worker_threads');
+const { inspect } = require('util');
+const assert = require('assert');
+
+// This test checks BroadcastChannel custom inspect outputs
+
+{
+ const bc = new BroadcastChannel('name');
+ assert.throws(() => bc[inspect.custom].call(), {
+ code: 'ERR_INVALID_THIS',
+ });
+ bc.close();
+}
+
+{
+ const bc = new BroadcastChannel('name');
+ assert.strictEqual(inspect(bc, { depth: -1 }), 'BroadcastChannel');
+ bc.close();
+}
+
+{
+ const bc = new BroadcastChannel('name');
+ assert.strictEqual(
+ inspect(bc),
+ "BroadcastChannel { name: 'name', active: true }"
+ );
+ bc.close();
+}
+
+{
+ const bc = new BroadcastChannel('name');
+ assert.strictEqual(
+ inspect(bc, { depth: null }),
+ "BroadcastChannel { name: 'name', active: true }"
+ );
+ bc.close();
+}