[Finishes #14177231] copy properties onto spy
This commit is contained in:
@@ -187,7 +187,7 @@ describe('Spies', function () {
|
|||||||
|
|
||||||
it('should be able to reset a spy', function() {
|
it('should be able to reset a spy', function() {
|
||||||
var TestClass = { someFunction: function() {} };
|
var TestClass = { someFunction: function() {} };
|
||||||
spyOn(TestClass, 'someFunction');
|
env.spyOn(TestClass, 'someFunction');
|
||||||
|
|
||||||
expect(TestClass.someFunction).not.toHaveBeenCalled();
|
expect(TestClass.someFunction).not.toHaveBeenCalled();
|
||||||
TestClass.someFunction();
|
TestClass.someFunction();
|
||||||
@@ -197,6 +197,16 @@ describe('Spies', function () {
|
|||||||
expect(TestClass.someFunction.calls.count()).toEqual(0);
|
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() {
|
describe("createSpyObj", function() {
|
||||||
it("should create an object with a bunch of spy methods when you call jasmine.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']);
|
var spyObj = j$.createSpyObj('BaseName', ['method1', 'method2']);
|
||||||
|
|||||||
@@ -68,6 +68,10 @@ getJasmineRequireObj().base = function(j$) {
|
|||||||
spy.and = spyStrategy;
|
spy.and = spyStrategy;
|
||||||
spy.calls = callTracker;
|
spy.calls = callTracker;
|
||||||
|
|
||||||
|
for (prop in originalFn) {
|
||||||
|
spy[prop] = originalFn[prop];
|
||||||
|
}
|
||||||
|
|
||||||
return spy;
|
return spy;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user