Skip to content

Commit 2777bc4

Browse files
blacksun1rvagg
authored andcommitted
test: remove unused function arguments in async-hooks tests
Remove unused function arguments in three async-hooks tests and improve test consistancy. PR-URL: #24406 Reviewed-By: Weijia Wang <starkwang@126.com> Reviewed-By: Refael Ackermann <refack@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent ed78339 commit 2777bc4

3 files changed

+14
-16
lines changed

test/async-hooks/test-promise.chain-promise-before-init-hooks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ const { checkInvocations } = require('./hook-checks');
88
if (!common.isMainThread)
99
common.skip('Worker bootstrapping works differently -> different async IDs');
1010

11-
const p = new Promise(common.mustCall(function executor(resolve, reject) {
11+
const p = new Promise(common.mustCall(function executor(resolve) {
1212
resolve(5);
1313
}));
1414

15-
p.then(function afterresolution(val) {
15+
p.then(function afterResolution(val) {
1616
assert.strictEqual(val, 5);
1717
return val;
1818
});

test/async-hooks/test-promise.js

+10-12
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,22 @@ const hooks = initHooks();
1313

1414
hooks.enable();
1515

16-
const p = (new Promise(common.mustCall(executor)));
17-
p.then(afterresolution);
18-
19-
function executor(resolve, reject) {
20-
const as = hooks.activitiesOfTypes('PROMISE');
21-
assert.strictEqual(as.length, 1);
22-
const a = as[0];
23-
checkInvocations(a, { init: 1 }, 'while in promise executor');
24-
resolve(5);
25-
}
26-
27-
function afterresolution(val) {
16+
const p = new Promise(common.mustCall(executor));
17+
p.then(function afterResolution(val) {
2818
assert.strictEqual(val, 5);
2919
const as = hooks.activitiesOfTypes('PROMISE');
3020
assert.strictEqual(as.length, 2);
3121
checkInvocations(as[0], { init: 1 }, 'after resolution parent promise');
3222
checkInvocations(as[1], { init: 1, before: 1 },
3323
'after resolution child promise');
24+
});
25+
26+
function executor(resolve) {
27+
const as = hooks.activitiesOfTypes('PROMISE');
28+
assert.strictEqual(as.length, 1);
29+
const a = as[0];
30+
checkInvocations(a, { init: 1 }, 'while in promise executor');
31+
resolve(5);
3432
}
3533

3634
process.on('exit', onexit);

test/async-hooks/test-promise.promise-before-init-hooks.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const assert = require('assert');
55
const initHooks = require('./init-hooks');
66
const { checkInvocations } = require('./hook-checks');
77

8-
const p = new Promise(common.mustCall(function executor(resolve, reject) {
8+
const p = new Promise(common.mustCall(function executor(resolve) {
99
resolve(5);
1010
}));
1111

1212
// init hooks after promise was created
1313
const hooks = initHooks({ allowNoInit: true });
1414
hooks.enable();
1515

16-
p.then(function afterresolution(val) {
16+
p.then(function afterResolution(val) {
1717
assert.strictEqual(val, 5);
1818
const as = hooks.activitiesOfTypes('PROMISE');
1919
assert.strictEqual(as.length, 1);

0 commit comments

Comments
 (0)