Merge branch 'enelson/spyonproperty' of https://github.com/elliot-nelson/jasmine into elliot-nelson-enelson/spyonproperty

- Merges #1705 from @elliot-nelson
This commit is contained in:
Gregg Van Hove
2019-05-17 16:20:19 -07:00
3 changed files with 46 additions and 22 deletions

View File

@@ -27,7 +27,7 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
}
if (obj[methodName] && j$.isSpy(obj[methodName]) ) {
if ( !!this.respy ){
if (this.respy) {
return obj[methodName];
}else {
throw new Error(getErrorMsg(methodName + ' has already been spied upon'));
@@ -91,8 +91,11 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
}
if (j$.isSpy(descriptor[accessType])) {
//TODO?: should this return the current spy? Downside: may cause user confusion about spy state
throw new Error(propertyName + ' has already been spied upon');
if (this.respy) {
return descriptor[accessType];
} else {
throw new Error(propertyName + '#' + accessType + ' has already been spied upon');
}
}
var originalDescriptor = j$.util.clone(descriptor),