Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test: refactor callback functions to arrow functions
Refactor callback functions to modern arrow functions.

Also, added `common.mustCall` to `online` callbacks.
  • Loading branch information
seanhealy committed Oct 12, 2018
commit d3a8ae0217c409c4a377d3daa6a01cf7f6519c23
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)));
}