diff --git a/lib/internal/test_runner/mock/mock.js b/lib/internal/test_runner/mock/mock.js index c7ca22b3f0ea4b..ad2af7765aac5f 100644 --- a/lib/internal/test_runner/mock/mock.js +++ b/lib/internal/test_runner/mock/mock.js @@ -140,7 +140,7 @@ class MockTracker { #mocks = []; #timers; - /** + /**. * Returns the mock timers of this MockTracker instance. * @returns {MockTimers} The mock timers instance. */ @@ -158,13 +158,13 @@ class MockTracker { * @returns {ProxyConstructor} The mock function tracker. */ fn( - original = function () {}, + original = function() {}, implementation = original, options = kEmptyObject, ) { if (original !== null && typeof original === 'object') { options = original; - original = function () { }; + original = function() {}; implementation = original; } else if (implementation !== null && typeof implementation === 'object') { options = implementation; @@ -272,11 +272,14 @@ class MockTracker { } /** - * Mocks a getter method of an object. + * Mocks a getter method of an object. This is a syntax sugar for the MockTracker.method with options.getter set to true * @param {Object} object - The target object. * @param {string} methodName - The name of the getter method to be mocked. * @param {function} [implementation] - An optional replacement function for the targeted method. * @param {Object} [options] - Additional tracking options. + * @param {boolean} [options.getter=true] - Indicates whether this is a getter method. + * @param {boolean} [options.setter=false] - Indicates whether this is a setter method. + * @param {number} [options.times=Infinity] - The maximum number of times the mock method can be called. * @returns {ProxyConstructor} The mock method tracker. */ getter( @@ -308,11 +311,14 @@ class MockTracker { } /** - * Mocks a setter method of an object. + * Mocks a setter method of an object. This function is a syntax sugar for MockTracker.method with options.setter set to true. * @param {Object} object - The target object. * @param {string} methodName - The setter method to be mocked. * @param {function} [implementation] - An optional replacement function for the targeted method. * @param {Object} [options] - Additional tracking options. + * @param {boolean} [options.getter=false] - Indicates whether this is a getter method. + * @param {boolean} [options.setter=true] - Indicates whether this is a setter method. + * @param {number} [options.times=Infinity] - The maximum number of times the mock method can be called. * @returns {ProxyConstructor} The mock method tracker. */ setter(