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:
parent
8059ff2f0b
commit
541367ac8e
@ -234,17 +234,6 @@ fail.
|
|||||||
|
|
||||||
If `fn` is not provided, an empty function will be used.
|
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])
|
### mustCallAtLeast([fn][, minimum])
|
||||||
* `fn` [<Function>] default = () => {}
|
* `fn` [<Function>] default = () => {}
|
||||||
* `minimum` [<number>] default = 1
|
* `minimum` [<number>] default = 1
|
||||||
|
@ -308,12 +308,6 @@ function mustCallAtLeast(fn, minimum) {
|
|||||||
return _mustCallInner(fn, minimum, '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) {
|
function _mustCallInner(fn, criteria = 1, field) {
|
||||||
if (process._exiting)
|
if (process._exiting)
|
||||||
throw new Error('Cannot use common.mustCall*() in process exit handler');
|
throw new Error('Cannot use common.mustCall*() in process exit handler');
|
||||||
@ -722,7 +716,6 @@ module.exports = {
|
|||||||
isWindows,
|
isWindows,
|
||||||
localIPv6Hosts,
|
localIPv6Hosts,
|
||||||
mustCall,
|
mustCall,
|
||||||
mustCallAsync,
|
|
||||||
mustCallAtLeast,
|
mustCallAtLeast,
|
||||||
mustNotCall,
|
mustNotCall,
|
||||||
nodeProcessAborted,
|
nodeProcessAborted,
|
||||||
|
@ -26,7 +26,6 @@ const {
|
|||||||
allowGlobals,
|
allowGlobals,
|
||||||
mustCall,
|
mustCall,
|
||||||
mustCallAtLeast,
|
mustCallAtLeast,
|
||||||
mustCallAsync,
|
|
||||||
hasMultiLocalhost,
|
hasMultiLocalhost,
|
||||||
skipIfEslintMissing,
|
skipIfEslintMissing,
|
||||||
canCreateSymLink,
|
canCreateSymLink,
|
||||||
@ -74,7 +73,6 @@ export {
|
|||||||
allowGlobals,
|
allowGlobals,
|
||||||
mustCall,
|
mustCall,
|
||||||
mustCallAtLeast,
|
mustCallAtLeast,
|
||||||
mustCallAsync,
|
|
||||||
hasMultiLocalhost,
|
hasMultiLocalhost,
|
||||||
skipIfEslintMissing,
|
skipIfEslintMissing,
|
||||||
canCreateSymLink,
|
canCreateSymLink,
|
||||||
|
@ -12,7 +12,7 @@ const makeDuplexPair = require('../common/duplexpair');
|
|||||||
{
|
{
|
||||||
let req;
|
let req;
|
||||||
const server = http2.createServer();
|
const server = http2.createServer();
|
||||||
server.on('stream', common.mustCallAsync(async (stream, headers) => {
|
server.on('stream', mustCallAsync(async (stream, headers) => {
|
||||||
stream.respond({
|
stream.respond({
|
||||||
'content-type': 'text/html',
|
'content-type': 'text/html',
|
||||||
':status': 200
|
':status': 200
|
||||||
@ -45,3 +45,9 @@ function event(ee, eventName) {
|
|||||||
ee.once(eventName, common.mustCall(resolve));
|
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);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user