Monday, 15 February 2010

AngularJS testing : Jasmine mock callback -


I have basic angular JS knowledge but I'm very new to the Jasmine unit test. My problem is:

I need to check a service method (method from myService):

  myService.method = function (args) {var parameter = "MyParam"; Another service. Otherwise (the parameter, function (result) {// test to use the content result (result == "blubala") work of examination ("param");}); };  

How can I duplicate another service? Other results to give a result and to test the rest myservice.method?

Your help

What I wanted to do was to create a fake function for my AJAX call and its arguments were used:

  Outgoing On (another Service, 'another method'). And callfex (function () {Get the arguments: Fake result of AJAX call and callback counterfeit result = logic [0]; var callback = argument [1]; return callback (forgery razult);});  

No comments:

Post a Comment