From 2bbbdcb30efeb1592cd73a6be58f0fd836513240 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 --- 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 c3f2c5f6b8a7f1..b06fbaa891c95f 100644 --- a/test/common/README.md +++ b/test/common/README.md @@ -240,17 +240,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 75fe2e1548ea8a..ac3705ce3cbce3 100644 --- a/test/common/index.js +++ b/test/common/index.js @@ -313,12 +313,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'); @@ -728,7 +722,6 @@ module.exports = { isWOW64, localIPv6Hosts, mustCall, - mustCallAsync, mustCallAtLeast, mustNotCall, nodeProcessAborted, diff --git a/test/common/index.mjs b/test/common/index.mjs index 832f68a9ee0d3e..dae470eeccca79 100644 --- a/test/common/index.mjs +++ b/test/common/index.mjs @@ -27,7 +27,6 @@ const { allowGlobals, mustCall, mustCallAtLeast, - mustCallAsync, hasMultiLocalhost, skipIfEslintMissing, canCreateSymLink, @@ -76,7 +75,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); +}