Allow users to set a default spy strategy

This commit is contained in:
Elliot Nelson
2019-06-02 09:05:45 -04:00
parent 0644731680
commit 96786c793f
5 changed files with 110 additions and 4 deletions

View File

@@ -12,7 +12,7 @@ getJasmineRequireObj().Spy = function(j$) {
* @constructor
* @name Spy
*/
function Spy(name, originalFn, customStrategies, getPromise) {
function Spy(name, originalFn, customStrategies, defaultStrategyFn, getPromise) {
var numArgs = typeof originalFn === 'function' ? originalFn.length : 0,
wrapper = makeFunc(numArgs, function() {
return spy.apply(this, Array.prototype.slice.call(arguments));
@@ -127,6 +127,10 @@ getJasmineRequireObj().Spy = function(j$) {
};
wrapper.calls = callTracker;
if (defaultStrategyFn) {
defaultStrategyFn(wrapper.and);
}
return wrapper;
}