node/test/parallel/test-broadcastchannel-custom-inspect.js
Yoshiki Kurihara 10b043287c
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>
2022-01-20 22:41:45 +00:00

41 lines
843 B
JavaScript

'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();
}