From 7ec18fb5f00849fb926f535865fc587bc11f253a Mon Sep 17 00:00:00 2001 From: Quinn Langille Date: Fri, 12 Oct 2018 09:53:59 -0700 Subject: [PATCH] test: removed mustCallAsync from common and added inside testcase PR-URL: https://github.com/nodejs/node/pull/23467 Reviewed-By: Gireesh Punathil Reviewed-By: James M Snell Reviewed-By: Trivikram Kamat --- test/common/README.md | 11 ----------- test/common/index.js | 7 ------- test/common/index.mjs | 2 -- test/parallel/test-http2-backpressure.js | 8 +++++++- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/test/common/README.md b/test/common/README.md index 0a2281b091b267..63b7905113f577 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -234,17 +234,6 @@ fail. If `fn` is not provided, an empty function will be used. -### mustCallAsync([fn][, exact]) -* `fn` [<Function>] -* `exact` [<number>] default = 1 -* return [<Function>] - -The same as `mustCall()`, except that it is also checked that the Promise -returned by the function is fulfilled for each invocation of the function. - -The return value of the wrapped function is the return value of the original -function, if necessary wrapped as a promise. - ### mustCallAtLeast([fn][, minimum]) * `fn` [<Function>] default = () => {} * `minimum` [<number>] default = 1 diff --git a/test/common/index.js b/test/common/index.js index f8f5b08b8a7116..4930f6163e8fde 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -308,12 +308,6 @@ function mustCallAtLeast(fn, minimum) { return _mustCallInner(fn, minimum, 'minimum'); } -function mustCallAsync(fn, exact) { - return mustCall((...args) => { - return Promise.resolve(fn(...args)).then(mustCall((val) => val)); - }, exact); -} - function _mustCallInner(fn, criteria = 1, field) { if (process._exiting) throw new Error('Cannot use common.mustCall*() in process exit handler'); @@ -721,7 +715,6 @@ module.exports = { isWindows, localIPv6Hosts, mustCall, - mustCallAsync, mustCallAtLeast, mustNotCall, nodeProcessAborted, diff --git a/test/common/index.mjs b/test/common/index.mjs index bead7333d12e81..068dd35049c301 100644 --- a/test/common/index.mjs +++ b/test/common/index.mjs @@ -26,7 +26,6 @@ const { allowGlobals, mustCall, mustCallAtLeast, - mustCallAsync, hasMultiLocalhost, skipIfEslintMissing, canCreateSymLink, @@ -74,7 +73,6 @@ export { allowGlobals, mustCall, mustCallAtLeast, - mustCallAsync, hasMultiLocalhost, skipIfEslintMissing, canCreateSymLink, diff --git a/test/parallel/test-http2-backpressure.js b/test/parallel/test-http2-backpressure.js index db58e8da33df33..1f9687831eb1a8 100644 --- a/test/parallel/test-http2-backpressure.js +++ b/test/parallel/test-http2-backpressure.js @@ -12,7 +12,7 @@ const makeDuplexPair = require('../common/duplexpair'); { let req; const server = http2.createServer(); - server.on('stream', common.mustCallAsync(async (stream, headers) => { + server.on('stream', mustCallAsync(async (stream, headers) => { stream.respond({ 'content-type': 'text/html', ':status': 200 @@ -45,3 +45,9 @@ function event(ee, eventName) { ee.once(eventName, common.mustCall(resolve)); }); } + +function mustCallAsync(fn, exact) { + return common.mustCall((...args) => { + return Promise.resolve(fn(...args)).then(common.mustCall((val) => val)); + }, exact); +}