Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 2d25cdd

Browse filesBrowse files
blacksun1codebytere
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 7fd4ef7 commit 2d25cdd
Copy full SHA for 2d25cdd

File tree

Expand file treeCollapse file tree

3 files changed

+14
-16
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+14
-16
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: test/async-hooks/test-promise.chain-promise-before-init-hooks.js
+2-2Lines 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-
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
});
Collapse file

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

Copy file name to clipboardExpand all lines: test/async-hooks/test-promise.js
+10-12Lines 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-
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);
Collapse file

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

Copy file name to clipboardExpand all lines: test/async-hooks/test-promise.promise-before-init-hooks.js
+2-2Lines changed: 2 additions & 2 deletions
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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.