I have basic angular JS knowledge but I'm very new to Jasmine unit testing. My issue is the following :
I need to test a service method (method from myService) :
myService.method = function(args)
{
    var parameter = "myParam";
    anotherService.anotherMethod(parameter, function(result)
    {
        //Stuff to test using result
        if(result == "blabla")
            testFunction("param");
    });
};
How can I mock anotherService.anotherMethod to return a result and test the rest of myService.method ? I need to check that for example that testFunction has been called with "param" (with expect(myFunction)toHaveBeenCalledWith("param")).
Thansk for your help
What I wanted to do was create a fake function for my AJAX call and use one its arguments :
spyOn(anotherService, 'anotherMethod').and.CallFake(function(){
  //Get args : fake result of AJAX call and callback
  var fakeResult = arguments[0];
  var callback = arguments[1];
  return callback(fakeResult);
});
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With