Reputation: 59
I'm having a method called doLogin that calls another method login from another object.
doLogin : function(data) {
var userMgtRequest = new UserMgtRequest();
userMgtRequest.setLoginId(data.username);
userMgtRequest.setLoginPwd(data.password);
var callback = this.callbackLogin;
userMgtManager.login(userMgtRequest, callback);
}
I am trying to test, with jasmine, if the in-function login is really being called or not when I call the main function. So I put a couple of spies on the two functions and using "andCallThrough()" to go into the actual implementation. But when I do call the first (doLogin) function
logInController.doLogin(data);
I get this error : TypeError: Cannot read property 'apply' of undefined
Tracked it with Jasmine to this call :
jasmine.createSpy = function(name) {
var spyObj = function() {
spyObj.wasCalled = true;
spyObj.callCount++;
var args = jasmine.util.argsToArray(arguments);
spyObj.mostRecentCall.object = this;
spyObj.mostRecentCall.args = args;
spyObj.argsForCall.push(args);
spyObj.calls.push({object: this, args: args});
return spyObj.plan.apply(this, arguments);
};
Can anyone tell me what is the spyObj.plan property and why is it being undefined ?
**Edit : Looking at the jasmine.js source file, I have known that the plan property is the function the spy is going to call depending on how it have been called. jasmine.js.source
Upvotes: 0
Views: 746
Reputation: 59
It appeared that I was malforming the definition of my file. Same problem resolved here : Mismatched definition
Upvotes: 0