Skip to content

Commit

Permalink
test: fix common.mustCall length and name properties
Browse files Browse the repository at this point in the history
Reassign `name` and `length` properties to the returned function to not
break code that relies on it.
  • Loading branch information
aduh95 committed Apr 29, 2021
1 parent c791019 commit 92b358a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion test/common/index.js
Expand Up @@ -387,10 +387,25 @@ function _mustCallInner(fn, criteria = 1, field) {

mustCallChecks.push(context);

return function() {
const _return = function() { // eslint-disable-line func-style
context.actual++;
return fn.apply(this, arguments);
};
Object.defineProperties(_return, {
name: {
value: fn.name,
writable: false,
enumerable: false,
configurable: true,
},
length: {
value: fn.length,
writable: false,
enumerable: false,
configurable: true,
},
});
return _return;
}

function hasMultiLocalhost() {
Expand Down

0 comments on commit 92b358a

Please sign in to comment.