Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: removed mustCallAsync from common and added inside testcase #23467

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions test/common/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions test/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -728,7 +722,6 @@ module.exports = {
isWOW64,
localIPv6Hosts,
mustCall,
mustCallAsync,
mustCallAtLeast,
mustNotCall,
nodeProcessAborted,
Expand Down
2 changes: 0 additions & 2 deletions test/common/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const {
allowGlobals,
mustCall,
mustCallAtLeast,
mustCallAsync,
hasMultiLocalhost,
skipIfEslintMissing,
canCreateSymLink,
Expand Down Expand Up @@ -76,7 +75,6 @@ export {
allowGlobals,
mustCall,
mustCallAtLeast,
mustCallAsync,
hasMultiLocalhost,
skipIfEslintMissing,
canCreateSymLink,
Expand Down
8 changes: 7 additions & 1 deletion test/parallel/test-http2-backpressure.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}