Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: remove unused function arguments in async-hooks tests #24406

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const { checkInvocations } = require('./hook-checks');
if (!common.isMainThread)
common.skip('Worker bootstrapping works differently -> different async IDs');

const p = new Promise(common.mustCall(function executor(resolve, reject) {
const p = new Promise(common.mustCall(function executor(resolve) {
resolve(5);
}));

p.then(function afterresolution(val) {
p.then(function afterResolution(val) {
assert.strictEqual(val, 5);
return val;
});
Expand Down
22 changes: 10 additions & 12 deletions test/async-hooks/test-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,22 @@ const hooks = initHooks();

hooks.enable();

const p = (new Promise(common.mustCall(executor)));
p.then(afterresolution);

function executor(resolve, reject) {
const as = hooks.activitiesOfTypes('PROMISE');
assert.strictEqual(as.length, 1);
const a = as[0];
checkInvocations(a, { init: 1 }, 'while in promise executor');
resolve(5);
}

function afterresolution(val) {
const p = new Promise(common.mustCall(executor));
p.then(function afterResolution(val) {
refack marked this conversation as resolved.
Show resolved Hide resolved
assert.strictEqual(val, 5);
const as = hooks.activitiesOfTypes('PROMISE');
assert.strictEqual(as.length, 2);
checkInvocations(as[0], { init: 1 }, 'after resolution parent promise');
checkInvocations(as[1], { init: 1, before: 1 },
'after resolution child promise');
});

function executor(resolve) {
const as = hooks.activitiesOfTypes('PROMISE');
assert.strictEqual(as.length, 1);
const a = as[0];
checkInvocations(a, { init: 1 }, 'while in promise executor');
resolve(5);
}

process.on('exit', onexit);
Expand Down
4 changes: 2 additions & 2 deletions test/async-hooks/test-promise.promise-before-init-hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ const assert = require('assert');
const initHooks = require('./init-hooks');
const { checkInvocations } = require('./hook-checks');

const p = new Promise(common.mustCall(function executor(resolve, reject) {
const p = new Promise(common.mustCall(function executor(resolve) {
resolve(5);
}));

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

p.then(function afterresolution(val) {
p.then(function afterResolution(val) {
assert.strictEqual(val, 5);
const as = hooks.activitiesOfTypes('PROMISE');
assert.strictEqual(as.length, 1);
Expand Down