Skip to content

Commit

Permalink
test: remove unused function arguments in async-hooks tests
Browse files Browse the repository at this point in the history
Remove unused function arguments in three async-hooks tests and
improve test consistancy.

PR-URL: #24406
Reviewed-By: Weijia Wang <[email protected]>
Reviewed-By: Refael Ackermann <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
blacksun1 authored and codebytere committed Jan 29, 2019
1 parent 7fd4ef7 commit 2d25cdd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 16 deletions.
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) {
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

0 comments on commit 2d25cdd

Please sign in to comment.