@@ -3523,11 +3523,11 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|||||||
|
|
||||||
this.spyOn = function(obj, methodName) {
|
this.spyOn = function(obj, methodName) {
|
||||||
|
|
||||||
if (j$.util.isUndefined(obj)) {
|
if (j$.util.isUndefined(obj) || obj === null) {
|
||||||
throw new Error(getErrorMsg('could not find an object to spy upon for ' + methodName + '()'));
|
throw new Error(getErrorMsg('could not find an object to spy upon for ' + methodName + '()'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j$.util.isUndefined(methodName)) {
|
if (j$.util.isUndefined(methodName) || methodName === null) {
|
||||||
throw new Error(getErrorMsg('No method name supplied'));
|
throw new Error(getErrorMsg('No method name supplied'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,22 @@ describe("SpyRegistry", function() {
|
|||||||
}).toThrowError(/No method name supplied/);
|
}).toThrowError(/No method name supplied/);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("checks that the object is not `null`", function() {
|
||||||
|
var spyRegistry = new jasmineUnderTest.SpyRegistry();
|
||||||
|
expect(function() {
|
||||||
|
spyRegistry.spyOn(null, 'pants');
|
||||||
|
}).toThrowError(/could not find an object/);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("checks that the method name is not `null`", function() {
|
||||||
|
var spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||||
|
subject = {};
|
||||||
|
|
||||||
|
expect(function() {
|
||||||
|
spyRegistry.spyOn(subject, null);
|
||||||
|
}).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 jasmineUnderTest.SpyRegistry(),
|
var spyRegistry = new jasmineUnderTest.SpyRegistry(),
|
||||||
subject = {};
|
subject = {};
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ getJasmineRequireObj().SpyRegistry = function(j$) {
|
|||||||
|
|
||||||
this.spyOn = function(obj, methodName) {
|
this.spyOn = function(obj, methodName) {
|
||||||
|
|
||||||
if (j$.util.isUndefined(obj)) {
|
if (j$.util.isUndefined(obj) || obj === null) {
|
||||||
throw new Error(getErrorMsg('could not find an object to spy upon for ' + methodName + '()'));
|
throw new Error(getErrorMsg('could not find an object to spy upon for ' + methodName + '()'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j$.util.isUndefined(methodName)) {
|
if (j$.util.isUndefined(methodName) || methodName === null) {
|
||||||
throw new Error(getErrorMsg('No method name supplied'));
|
throw new Error(getErrorMsg('No method name supplied'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user