@@ -1232,6 +1232,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.createSpy = function(name, originalFn) {
|
this.createSpy = function(name, originalFn) {
|
||||||
|
if (arguments.length === 1 && j$.isFunction_(name)) {
|
||||||
|
originalFn = name;
|
||||||
|
name = originalFn.name;
|
||||||
|
}
|
||||||
|
|
||||||
return spyFactory.createSpy(name, originalFn);
|
return spyFactory.createSpy(name, originalFn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,13 @@ describe('Spies', function () {
|
|||||||
expect(spy.bob).toEqual("test");
|
expect(spy.bob).toEqual("test");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("should allow you to omit the name argument and only pass the originalFn argument", function() {
|
||||||
|
var fn = function test() {};
|
||||||
|
var spy = env.createSpy(fn);
|
||||||
|
|
||||||
|
expect(spy.and.identity).toEqual("test");
|
||||||
|
})
|
||||||
|
|
||||||
it("warns the user that we intend to overwrite an existing property", function() {
|
it("warns the user that we intend to overwrite an existing property", function() {
|
||||||
TestClass.prototype.someFunction.and = "turkey";
|
TestClass.prototype.someFunction.and = "turkey";
|
||||||
|
|
||||||
|
|||||||
@@ -474,6 +474,11 @@ getJasmineRequireObj().Env = function(j$) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
this.createSpy = function(name, originalFn) {
|
this.createSpy = function(name, originalFn) {
|
||||||
|
if (arguments.length === 1 && j$.isFunction_(name)) {
|
||||||
|
originalFn = name;
|
||||||
|
name = originalFn.name;
|
||||||
|
}
|
||||||
|
|
||||||
return spyFactory.createSpy(name, originalFn);
|
return spyFactory.createSpy(name, originalFn);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user