mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
Tests should be explicit regarding whether a promise is expected to settle, and the test should fail when the behavior does not meet expectations. PR-URL: https://github.com/nodejs/node/pull/60976 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Erick Wendel <erick.workspace@gmail.com>
21 lines
655 B
JavaScript
21 lines
655 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Worker } = require('worker_threads');
|
|
|
|
// Test that calling worker.terminate() if kHandler is null should return an
|
|
// empty promise that resolves to undefined, even when a callback is passed
|
|
|
|
const worker = new Worker(`
|
|
const { parentPort } = require('worker_threads');
|
|
parentPort.postMessage({ hello: 'world' });
|
|
`, { eval: true });
|
|
|
|
process.once('beforeExit', common.mustCall(() => worker.ref()));
|
|
|
|
worker.on('exit', common.mustCall(() => {
|
|
worker.terminate().then((res) => assert.strictEqual(res, undefined)).then(common.mustCall());
|
|
}));
|
|
|
|
worker.unref();
|