Skip to content

Commit ed7dd93

Browse files
GaryGSCtargos
authored andcommitted
test: use arrow functions in async-hooks tests
Convert all anonymous callback functions in `test/async-hooks/*.js` to use arrow functions. `writing-tests.md` states to use arrow functions when appropriate. PR-URL: #30137 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]>
1 parent b802d51 commit ed7dd93

6 files changed

+13
-13
lines changed

test/async-hooks/test-disable-in-init.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const fs = require('fs');
77
let nestedCall = false;
88

99
async_hooks.createHook({
10-
init: common.mustCall(function() {
10+
init: common.mustCall(() => {
1111
nestedHook.disable();
1212
if (!nestedCall) {
1313
nestedCall = true;

test/async-hooks/test-graph.http.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,19 @@ const http = require('http');
1111
const hooks = initHooks();
1212
hooks.enable();
1313

14-
const server = http.createServer(common.mustCall(function(req, res) {
14+
const server = http.createServer(common.mustCall((req, res) => {
1515
res.end();
16-
this.close(common.mustCall());
16+
server.close(common.mustCall());
1717
}));
18-
server.listen(0, common.mustCall(function() {
18+
server.listen(0, common.mustCall(() => {
1919
http.get({
2020
host: '::1',
2121
family: 6,
2222
port: server.address().port
2323
}, common.mustCall());
2424
}));
2525

26-
process.on('exit', function() {
26+
process.on('exit', () => {
2727
hooks.disable();
2828

2929
verifyGraph(

test/async-hooks/test-graph.pipeconnect.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ tmpdir.refresh();
1212
const hooks = initHooks();
1313
hooks.enable();
1414

15-
net.createServer(function(c) {
15+
const server = net.createServer((c) => {
1616
c.end();
17-
this.close();
17+
server.close();
1818
}).listen(common.PIPE, common.mustCall(onlisten));
1919

2020
function onlisten() {

test/async-hooks/test-nexttick-default-trigger.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ hooks.enable();
1414

1515
const rootAsyncId = async_hooks.executionAsyncId();
1616

17-
process.nextTick(common.mustCall(function() {
17+
process.nextTick(common.mustCall(() => {
1818
assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId);
1919
}));
2020

21-
process.on('exit', function() {
21+
process.on('exit', () => {
2222
hooks.sanityCheck();
2323

2424
const as = hooks.activitiesOfTypes('TickObject');

test/async-hooks/test-pipeconnectwrap.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ let pipe1, pipe2;
1717
let pipeserver;
1818
let pipeconnect;
1919

20-
net.createServer(common.mustCall(function(c) {
20+
const server = net.createServer(common.mustCall((c) => {
2121
c.end();
22-
this.close();
22+
server.close();
2323
process.nextTick(maybeOnconnect.bind(null, 'server'));
2424
})).listen(common.PIPE, common.mustCall(onlisten));
2525

test/async-hooks/test-queue-microtask.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ hooks.enable();
1111

1212
const rootAsyncId = async_hooks.executionAsyncId();
1313

14-
queueMicrotask(common.mustCall(function() {
14+
queueMicrotask(common.mustCall(() => {
1515
assert.strictEqual(async_hooks.triggerAsyncId(), rootAsyncId);
1616
}));
1717

18-
process.on('exit', function() {
18+
process.on('exit', () => {
1919
hooks.sanityCheck();
2020

2121
const as = hooks.activitiesOfTypes('Microtask');

0 commit comments

Comments
 (0)