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

@@ -330,5 +330,21 @@ getJasmineRequireObj().interface = function(jasmine, env) {
return env.addSpyStrategy(name, factory);
};
/**
* Set the default spy strategy for the current scope of specs.
*
* _Note:_ This is only callable from within a {@link beforeEach}, {@link it}, or {@link beforeAll}.
* @name jasmine.setDefaultSpyStrategy
* @function
* @param {Function} defaultStrategyFn - a function that assigns a strategy
* @example
* beforeEach(function() {
* jasmine.setDefaultSpyStrategy(and => and.returnValue(true));
* });
*/
jasmine.setDefaultSpyStrategy = function(defaultStrategyFn) {
return env.setDefaultSpyStrategy(defaultStrategyFn);
};
return jasmineInterface;
};