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

- Merges #1699 from @elliot-nelson
- Fixes #1677
This commit is contained in:
Gregg Van Hove
2019-05-14 18:00:20 -07:00
3 changed files with 73 additions and 13 deletions

View File

@@ -6471,13 +6471,25 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
throw new Error('spyOnAllFunctions could not find an object to spy upon');
}
for (var prop in obj) {
if (Object.prototype.hasOwnProperty.call(obj, prop) && obj[prop] instanceof Function) {
var descriptor = Object.getOwnPropertyDescriptor(obj, prop);
if ((descriptor.writable || descriptor.set) && descriptor.configurable) {
this.spyOn(obj, prop);
var pointer = obj,
props = [],
prop,
descriptor;
while (pointer) {
for (prop in pointer) {
if (Object.prototype.hasOwnProperty.call(pointer, prop) && pointer[prop] instanceof Function) {
descriptor = Object.getOwnPropertyDescriptor(pointer, prop);
if ((descriptor.writable || descriptor.set) && descriptor.configurable) {
props.push(prop);
}
}
}
pointer = Object.getPrototypeOf(pointer);
}
for (var i = 0; i < props.length; i++) {
this.spyOn(obj, props[i]);
}
return obj;