Merge branch 'spy-arity-preservation' of https://github.com/kapke/jasmine into kapke-spy-arity-preservation

- Merges #1055 from @kapke
- Fixes #991
This commit is contained in:
Gregg Van Hove
2016-09-27 15:41:40 -07:00
5 changed files with 139 additions and 64 deletions

View File

@@ -71,38 +71,7 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
};
j$.createSpy = function(name, originalFn) {
var spyStrategy = new j$.SpyStrategy({
name: name,
fn: originalFn,
getSpy: function() { return spy; }
}),
callTracker = new j$.CallTracker(),
spy = function() {
var callData = {
object: this,
args: Array.prototype.slice.apply(arguments)
};
callTracker.track(callData);
var returnValue = spyStrategy.exec.apply(this, arguments);
callData.returnValue = returnValue;
return returnValue;
};
for (var prop in originalFn) {
if (prop === 'and' || prop === 'calls') {
throw new Error('Jasmine spies would overwrite the \'and\' and \'calls\' properties on the object being spied upon');
}
spy[prop] = originalFn[prop];
}
spy.and = spyStrategy;
spy.calls = callTracker;
return spy;
return j$.Spy(name, originalFn);
};
j$.isSpy = function(putativeSpy) {