From f7a50f76eeb1bc8107cab440ea71328b2c6c6899 Mon Sep 17 00:00:00 2001 From: Sean Healy Date: Fri, 12 Oct 2018 10:43:47 -0700 Subject: [PATCH] test: refactor callback functions to arrow functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refactor callback functions to modern arrow functions. Also, added `common.mustCall` to `online` callbacks. PR-URL: https://github.com/nodejs/node/pull/23546 Reviewed-By: James M Snell Reviewed-By: Сковорода Никита Андреевич Reviewed-By: Trivikram Kamat Reviewed-By: Ruben Bridgewater --- .../test-cluster-worker-forced-exit.js | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/test/parallel/test-cluster-worker-forced-exit.js b/test/parallel/test-cluster-worker-forced-exit.js index 6a6046f23c4dd1..cc76b4ba3aff3a 100644 --- a/test/parallel/test-cluster-worker-forced-exit.js +++ b/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))); }