lundi 4 juillet 2016

How to test Third party library functions in angular unit testing

I am testing angular services using angular unit testing with karma and jasmine . In my services I have used sprintf() of sprintf-js module to get the generate string . Now when I tried to test service it gives error sprintf not defined .

code is something like this :

myservice.js

abc(a,b){
var url = sprintf(a,b);
ajax.get(url);
}

myservice.spec.js : I have injected the myservice in this file and used it -

myservice.abc(dummya, dummyb);

$rootScope.$appy();

expect(myservice.abc).toHaveBeenCalled();

Any help appreciated .

Aucun commentaire:

Enregistrer un commentaire