Skip to content
Permalink
Browse files

test: refactor callback functions to arrow functions

Refactor callback functions to modern arrow functions.

Also, added `common.mustCall` to `online` callbacks.

PR-URL: #23546
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
  • Loading branch information
seanhealy authored and MylesBorins committed Oct 12, 2018
1 parent 299285a commit d54e15f6f7aad5a90a31c63377b6de86c0292b5f
Showing with 10 additions and 12 deletions.
  1. +10 −12 test/parallel/test-cluster-worker-forced-exit.js
@@ -37,10 +37,8 @@ const SENTINEL = 42;
// 3 disconnect worker with child_process's disconnect, confirm
// no sentinel value
if (cluster.isWorker) {
process.on('disconnect', function(msg) {
setTimeout(function() {
process.exit(SENTINEL);
}, 10);
process.on('disconnect', (msg) => {
setTimeout(() => process.exit(SENTINEL), 10);
});
return;
}
@@ -49,17 +47,17 @@ checkUnforced();
checkForced();

function checkUnforced() {
cluster.fork()
.on('online', function() { this.disconnect(); })
.on('exit', common.mustCall(function(status) {
const worker = cluster.fork();
worker
.on('online', common.mustCall(() => worker.disconnect()))
.on('exit', common.mustCall((status) => {
assert.strictEqual(status, SENTINEL);
}));
}

function checkForced() {
cluster.fork()
.on('online', function() { this.process.disconnect(); })
.on('exit', common.mustCall(function(status) {
assert.strictEqual(status, 0);
}));
const worker = cluster.fork();
worker
.on('online', common.mustCall(() => worker.process.disconnect()))
.on('exit', common.mustCall((status) => assert.strictEqual(status, 0)));
}

0 comments on commit d54e15f

Please sign in to comment.
You can’t perform that action at this time.