lundi 25 janvier 2016

AngularJs Provider: understanding this AngularJs Provider Code and how to unit test it

I was going through this blog, which talks about writing a LogService provider, by adding more functionality to the existing $log service.

I am not sure what this code is doing:

        Logger.getInstance = function(context) {
        return new Logger(context);
    }; // Line 10 in repo

As this is a service, and i am wondering we want a separate instance for each time the getInstance is called.

Unit Tests:

How do we unit test the service functions like log,info,warn,debug and error Below is gist,where i have written unit-tests to test the configuration part of the provider. However when i try to test the service functions i get undefined error. The functions are on the prototype of the LogService

Links: Blog / Github Repo

Aucun commentaire:

Enregistrer un commentaire