test: removed mustCallAsync from common and added inside testcase

PR-URL: https://github.com/nodejs/node/pull/23467
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
This commit is contained in:
Quinn Langille 2018-10-12 09:53:59 -07:00 committed by Anna Henningsen
parent 8059ff2f0b
commit 541367ac8e
No known key found for this signature in database
GPG Key ID: 9C63F3A6CD2AD8F9
4 changed files with 7 additions and 21 deletions

View File

@ -234,17 +234,6 @@ fail.
If `fn` is not provided, an empty function will be used.
### mustCallAsync([fn][, exact])
* `fn` [&lt;Function>]
* `exact` [&lt;number>] default = 1
* return [&lt;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` [&lt;Function>] default = () => {}
* `minimum` [&lt;number>] default = 1

View File

@ -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');
@ -722,7 +716,6 @@ module.exports = {
isWindows,
localIPv6Hosts,
mustCall,
mustCallAsync,
mustCallAtLeast,
mustNotCall,
nodeProcessAborted,

View File

@ -26,7 +26,6 @@ const {
allowGlobals,
mustCall,
mustCallAtLeast,
mustCallAsync,
hasMultiLocalhost,
skipIfEslintMissing,
canCreateSymLink,
@ -74,7 +73,6 @@ export {
allowGlobals,
mustCall,
mustCallAtLeast,
mustCallAsync,
hasMultiLocalhost,
skipIfEslintMissing,
canCreateSymLink,

View File

@ -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);
}