Hi Gurus,

I'm a total newbie on AngularJs and my question is certainly simple. I'm 
trying to test a service that has a decorated $log as a parameter. What 
would be the right approach? Mock the $log.getInstance() function or inject 
the decorated implementation into the test?

define(['angular'], function(angular) {
   'use strict';

   angular.module('myApp.services.MyApi', [])
      .factory('MyApi', function($q, $log) {
            $log = $log.getInstance('VimApi');
            init = function() {
                ...
            };

         // Public API
         return {
            init: init
         };
      });
});


define(['angular', 'angular-mocks', 'app'], function(angular, mocks, app) {
   'use strict';

   describe('Service: myApi', function () {

      var myApi;

      beforeEach(function() {

         //Mock getInstance?

         module('myApp.services.MyApi');
         inject(function ($log, _MyApi_) {
            myApi = _MyApi_;
         });
      });

      it('should initialize', function () {
         expect(!!myApi).toBe(true);
      });

   });
});


Any help is appreciated.

Cheers,
George


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to