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.
|
||||
|
||||
### 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
|
||||
|
@ -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,
|
||||
|
@ -26,7 +26,6 @@ const {
|
||||
allowGlobals,
|
||||
mustCall,
|
||||
mustCallAtLeast,
|
||||
mustCallAsync,
|
||||
hasMultiLocalhost,
|
||||
skipIfEslintMissing,
|
||||
canCreateSymLink,
|
||||
@ -74,7 +73,6 @@ export {
|
||||
allowGlobals,
|
||||
mustCall,
|
||||
mustCallAtLeast,
|
||||
mustCallAsync,
|
||||
hasMultiLocalhost,
|
||||
skipIfEslintMissing,
|
||||
canCreateSymLink,
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user