* Merges #1716 from @elliot-nelson
This commit is contained in:
Pivotal
2019-08-29 13:48:58 -07:00
committed by Steve Gravrock
6 changed files with 186 additions and 8 deletions

View File

@@ -222,6 +222,17 @@ getJasmineRequireObj().Env = function(j$) {
}
});
this.setDefaultSpyStrategy = function(defaultStrategyFn) {
if (!currentRunnable()) {
throw new Error(
'Default spy strategy must be set in a before function or a spec'
);
}
runnableResources[
currentRunnable().id
].defaultStrategyFn = defaultStrategyFn;
};
this.addSpyStrategy = function(name, fn) {
if (!currentRunnable()) {
throw new Error(
@@ -300,7 +311,8 @@ getJasmineRequireObj().Env = function(j$) {
spies: [],
customEqualityTesters: [],
customMatchers: {},
customSpyStrategies: {}
customSpyStrategies: {},
defaultStrategyFn: undefined
};
if (runnableResources[parentRunnableId]) {
@@ -310,6 +322,8 @@ getJasmineRequireObj().Env = function(j$) {
resources.customMatchers = j$.util.clone(
runnableResources[parentRunnableId].customMatchers
);
resources.defaultStrategyFn =
runnableResources[parentRunnableId].defaultStrategyFn;
}
runnableResources[id] = resources;
@@ -747,6 +761,15 @@ getJasmineRequireObj().Env = function(j$) {
return {};
},
function getDefaultStrategyFn() {
var runnable = currentRunnable();
if (runnable) {
return runnableResources[runnable.id].defaultStrategyFn;
}
return undefined;
},
function getPromise() {
return customPromise || global.Promise;
}