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

Lines changed: 14 additions & 16 deletions

File tree

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

Lines changed: 2 additions & 2 deletions
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-
constp=newPromise(common.mustCall(functionexecutor(resolve,reject){
11+
constp=newPromise(common.mustCall(functionexecutor(resolve){
1212
resolve(5);
1313
}));
1414

15-
p.then(functionafterresolution(val){
15+
p.then(functionafterResolution(val){
1616
assert.strictEqual(val,5);
1717
returnval;
1818
});

‎test/async-hooks/test-promise.js‎

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,22 @@ const hooks = initHooks();
1313

1414
hooks.enable();
1515

16-
constp=(newPromise(common.mustCall(executor)));
17-
p.then(afterresolution);
18-
19-
functionexecutor(resolve,reject){
20-
constas=hooks.activitiesOfTypes('PROMISE');
21-
assert.strictEqual(as.length,1);
22-
consta=as[0];
23-
checkInvocations(a,{init: 1},'while in promise executor');
24-
resolve(5);
25-
}
26-
27-
functionafterresolution(val){
16+
constp=newPromise(common.mustCall(executor));
17+
p.then(functionafterResolution(val){
2818
assert.strictEqual(val,5);
2919
constas=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+
functionexecutor(resolve){
27+
constas=hooks.activitiesOfTypes('PROMISE');
28+
assert.strictEqual(as.length,1);
29+
consta=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‎

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

8-
constp=newPromise(common.mustCall(functionexecutor(resolve,reject){
8+
constp=newPromise(common.mustCall(functionexecutor(resolve){
99
resolve(5);
1010
}));
1111

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

16-
p.then(functionafterresolution(val){
16+
p.then(functionafterResolution(val){
1717
assert.strictEqual(val,5);
1818
constas=hooks.activitiesOfTypes('PROMISE');
1919
assert.strictEqual(as.length,1);

0 commit comments

Comments
 (0)