diff --git a/spec/core/SpySpec.js b/spec/core/SpySpec.js index c11d2836..8ab87da1 100644 --- a/spec/core/SpySpec.js +++ b/spec/core/SpySpec.js @@ -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']); diff --git a/src/core/base.js b/src/core/base.js index 19b3a576..f4e106c7 100644 --- a/src/core/base.js +++ b/src/core/base.js @@ -68,6 +68,10 @@ getJasmineRequireObj().base = function(j$) { spy.and = spyStrategy; spy.calls = callTracker; + for (prop in originalFn) { + spy[prop] = originalFn[prop]; + } + return spy; };