From 336ec08c3a3a741dbb2601132e94cc84c4ce1f22 Mon Sep 17 00:00:00 2001
From: Simon Bruce
Date: Sat, 17 Nov 2018 15:58:39 +1030
Subject: [PATCH] test: remove unused function arguments in async-hooks tests
Remove unused function arguments in three async-hooks tests and
improve test consistancy.
---
...promise.chain-promise-before-init-hooks.js | 4 ++--
test/async-hooks/test-promise.js | 22 +++++++++----------
.../test-promise.promise-before-init-hooks.js | 4 ++--
3 files changed, 14 insertions(+), 16 deletions(-)
diff --git a/test/async-hooks/test-promise.chain-promise-before-init-hooks.js b/test/async-hooks/test-promise.chain-promise-before-init-hooks.js
index 9046bc3514abfc..341b7b4c5dfd89 100644
--- a/test/async-hooks/test-promise.chain-promise-before-init-hooks.js
+++ b/test/async-hooks/test-promise.chain-promise-before-init-hooks.js
@@ -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;
});
diff --git a/test/async-hooks/test-promise.js b/test/async-hooks/test-promise.js
index 729704b7928f7d..417cb3c80d6298 100644
--- a/test/async-hooks/test-promise.js
+++ b/test/async-hooks/test-promise.js
@@ -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);
diff --git a/test/async-hooks/test-promise.promise-before-init-hooks.js b/test/async-hooks/test-promise.promise-before-init-hooks.js
index 957d1a75e49f70..f9ba24c044298f 100644
--- a/test/async-hooks/test-promise.promise-before-init-hooks.js
+++ b/test/async-hooks/test-promise.promise-before-init-hooks.js
@@ -5,7 +5,7 @@ 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);
}));
@@ -13,7 +13,7 @@ const p = new Promise(common.mustCall(function executor(resolve, reject) {
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);