Merge branch '1189' of https://github.com/seanparmelee/jasmine into seanparmelee-1189
- Merges #1193 from @seanparmlee - Fixes #1189
This commit is contained in:
@@ -2093,7 +2093,9 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
restoreStrategy = function() {
|
restoreStrategy = function() {
|
||||||
delete obj[methodName];
|
if (!delete obj[methodName]) {
|
||||||
|
obj[methodName] = originalMethod;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -127,6 +127,29 @@ describe("SpyRegistry", function() {
|
|||||||
|
|
||||||
expect(subject.hasOwnProperty('spiedFunc')).toBe(false);
|
expect(subject.hasOwnProperty('spiedFunc')).toBe(false);
|
||||||
expect(subject.spiedFunc).toBe(originalFunction);
|
expect(subject.spiedFunc).toBe(originalFunction);
|
||||||
})
|
});
|
||||||
|
|
||||||
|
it("restores the original function when it\'s inherited and cannot be deleted", function() {
|
||||||
|
// IE 8 doesn't support `Object.create` or `Object.defineProperty`
|
||||||
|
if (jasmine.getEnv().ieVersion < 9) { return; }
|
||||||
|
|
||||||
|
var spies = [],
|
||||||
|
spyRegistry = new jasmineUnderTest.SpyRegistry({currentSpies: function() { return spies; }}),
|
||||||
|
originalFunction = function() {},
|
||||||
|
subjectParent = {spiedFunc: originalFunction};
|
||||||
|
|
||||||
|
var subject = Object.create(subjectParent);
|
||||||
|
|
||||||
|
spyRegistry.spyOn(subject, 'spiedFunc');
|
||||||
|
|
||||||
|
// simulate a spy that cannot be deleted
|
||||||
|
Object.defineProperty(subject, 'spiedFunc', {
|
||||||
|
configurable: false
|
||||||
|
});
|
||||||
|
|
||||||
|
spyRegistry.clearSpies();
|
||||||
|
|
||||||
|
expect(jasmineUnderTest.isSpy(subject.spiedFunc)).toBe(false);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
restoreStrategy = function() {
|
restoreStrategy = function() {
|
||||||
delete obj[methodName];
|
if (!delete obj[methodName]) {
|
||||||
|
obj[methodName] = originalMethod;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user