mercredi 24 février 2016

jasmine spyon method with bracket notation

Scenario:

myFunction = function(isRight){
    var whichMethod = isRight ? 'goRight': 'goLeft';
    RestCallService[whichMethod](function (someresponse){
      .....
  });

}

I need to spyOn method isRight/isLeft of RestCallService based upon value that i passed to myFunction.

spyOn(RestCallService,'isRight').and.callFake(function(response){
 response(data);
});

Getting following error: TypeError: Cannot set property 'id' of undefined

Aucun commentaire:

Enregistrer un commentaire