Struggling to unit test Angular, was this module the best approach?
Injecting the $injector service can help by facilitating the use of optional dependencies:

app.factory('templateRepository', [ '$injector', function($injector) {
  function lookupUrlFor(contentType) {
   // Do your translation here
  }

  return {
    getTemplate: function(contentType) {
      var templateCache = $injector.get('$templateCache');
      return templateCache.get(lookupUrlFor(contentType));
      }
    }
}])


That way the unit tests only needs to inject $injector and mocks can be avoided.

References


Optional Dependencies in Angular.js
Avoid circular dependencies with AngularJS Directives | endjin blog
ngMock / $httpBackend