Skip to content

Commit

Permalink
test: improve test coverage of internal/worker/io
Browse files Browse the repository at this point in the history
  • Loading branch information
kuriyosh authored and danielleadams committed Mar 14, 2022
1 parent 39f52e1 commit 1d3ef11
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/parallel/test-broadcastchannel-custom-inspect.js
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 1d3ef11

Please sign in to comment.