spyOn explicitly checks to see that a method name to spy on was passed.
[finish #27689237]
This commit is contained in:
@@ -1864,6 +1864,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|||||||
throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()');
|
throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (j$.util.isUndefined(methodName)) {
|
||||||
|
throw new Error('No method name supplied');
|
||||||
|
}
|
||||||
|
|
||||||
if (j$.util.isUndefined(obj[methodName])) {
|
if (j$.util.isUndefined(obj[methodName])) {
|
||||||
throw new Error(methodName + '() method does not exist');
|
throw new Error(methodName + '() method does not exist');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,15 @@ describe("SpyRegistry", function() {
|
|||||||
}).toThrowError(/could not find an object/);
|
}).toThrowError(/could not find an object/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("checks that a method name was passed", function() {
|
||||||
|
var spyRegistry = new j$.SpyRegistry(),
|
||||||
|
subject = {};
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
spyRegistry.spyOn(subject);
|
||||||
|
}).toThrowError(/No method name supplied/);
|
||||||
|
});
|
||||||
|
|
||||||
it("checks for the existence of the method", function() {
|
it("checks for the existence of the method", function() {
|
||||||
var spyRegistry = new j$.SpyRegistry(),
|
var spyRegistry = new j$.SpyRegistry(),
|
||||||
subject = {};
|
subject = {};
|
||||||
|
|||||||
@@ -9,6 +9,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|||||||
throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()');
|
throw new Error('spyOn could not find an object to spy upon for ' + methodName + '()');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (j$.util.isUndefined(methodName)) {
|
||||||
|
throw new Error('No method name supplied');
|
||||||
|
}
|
||||||
|
|
||||||
if (j$.util.isUndefined(obj[methodName])) {
|
if (j$.util.isUndefined(obj[methodName])) {
|
||||||
throw new Error(methodName + '() method does not exist');
|
throw new Error(methodName + '() method does not exist');
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user