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: nodejs#23546
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Сковорода Никита Андреевич <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
Reviewed-By: Ruben Bridgewater <[email protected]>
  • Loading branch information
seanhealy authored and BridgeAR committed Oct 15, 2018
1 parent 0f17c1c commit f7a50f7
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 f7a50f7

Please sign in to comment.