Skip to content

Commit

Permalink
test: refactor callback functions to arrow functions
Browse files Browse the repository at this point in the history
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 rvagg committed Nov 28, 2018
1 parent a0d903f commit de3ef4f
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions test/parallel/test-cluster-worker-forced-exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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 de3ef4f

Please sign in to comment.