Skip to content

Commit 4518ca9

Browse files
seanhealyjasnell
authored andcommitted
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>
1 parent c9afea9 commit 4518ca9

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

test/parallel/test-cluster-worker-forced-exit.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ const SENTINEL = 42;
3737
// 3 disconnect worker with child_process's disconnect, confirm
3838
// no sentinel value
3939
if (cluster.isWorker) {
40-
process.on('disconnect', function(msg) {
41-
setTimeout(function() {
42-
process.exit(SENTINEL);
43-
}, 10);
40+
process.on('disconnect', (msg) => {
41+
setTimeout(() => process.exit(SENTINEL), 10);
4442
});
4543
return;
4644
}
@@ -49,17 +47,17 @@ checkUnforced();
4947
checkForced();
5048

5149
function checkUnforced() {
52-
cluster.fork()
53-
.on('online', function() { this.disconnect(); })
54-
.on('exit', common.mustCall(function(status) {
50+
const worker = cluster.fork();
51+
worker
52+
.on('online', common.mustCall(() => worker.disconnect()))
53+
.on('exit', common.mustCall((status) => {
5554
assert.strictEqual(status, SENTINEL);
5655
}));
5756
}
5857

5958
function checkForced() {
60-
cluster.fork()
61-
.on('online', function() { this.process.disconnect(); })
62-
.on('exit', common.mustCall(function(status) {
63-
assert.strictEqual(status, 0);
64-
}));
59+
const worker = cluster.fork();
60+
worker
61+
.on('online', common.mustCall(() => worker.process.disconnect()))
62+
.on('exit', common.mustCall((status) => assert.strictEqual(status, 0)));
6563
}

0 commit comments

Comments
 (0)