spyOn explicitly checks to see that a method name to spy on was passed.

[finish #27689237]
This commit is contained in:
slackersoft
2014-12-16 13:21:48 -08:00
parent 7570bc422b
commit b4b3ac25a1
3 changed files with 17 additions and 0 deletions

View File

@@ -1864,6 +1864,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
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])) {
throw new Error(methodName + '() method does not exist');
}

View File

@@ -7,6 +7,15 @@ describe("SpyRegistry", function() {
}).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() {
var spyRegistry = new j$.SpyRegistry(),
subject = {};

View File

@@ -9,6 +9,10 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
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])) {
throw new Error(methodName + '() method does not exist');
}