[Finishes #14177231] copy properties onto spy

This commit is contained in:
Colin O'Byrne and JR Boyens
2013-07-22 14:54:43 -07:00
parent 663a58d617
commit 30aec66ce5
2 changed files with 15 additions and 1 deletions

View File

@@ -187,7 +187,7 @@ describe('Spies', function () {
it('should be able to reset a spy', function() {
var TestClass = { someFunction: function() {} };
spyOn(TestClass, 'someFunction');
env.spyOn(TestClass, 'someFunction');
expect(TestClass.someFunction).not.toHaveBeenCalled();
TestClass.someFunction();
@@ -197,6 +197,16 @@ describe('Spies', function () {
expect(TestClass.someFunction.calls.count()).toEqual(0);
});
it("preserves the properties of the spied function", function() {
var TestClass = function() {};
TestClass.prototype.someFunction = function() {};
TestClass.prototype.someFunction.bob = "test";
var spy = env.spyOn(TestClass.prototype, 'someFunction');
expect(spy.bob).toEqual("test");
});
describe("createSpyObj", function() {
it("should create an object with a bunch of spy methods when you call jasmine.createSpyObj()", function() {
var spyObj = j$.createSpyObj('BaseName', ['method1', 'method2']);

View File

@@ -68,6 +68,10 @@ getJasmineRequireObj().base = function(j$) {
spy.and = spyStrategy;
spy.calls = callTracker;
for (prop in originalFn) {
spy[prop] = originalFn[prop];
}
return spy;
};