title: Angular Jasmine UI router inject resolve value into test
body: <p>In my Angular app, UI router resolves a promise into the controller. When trying to test this controller, Karma is complaining about an unknown provider. How do I inject a fake object into the test to represent this resolve object.</p>
  
  <p>My app's code looks something like:</p>
  
  <pre><code>angular.module('myapp')
  .config(function($stateProvider, $urlRouterProvider) {
      $stateProvider
      .state('tab.name', {
          ...
          resolve: {
              allTemplates: function(Templates) {
                  return Templates.all().then(function(templates) {
                      return templates;
                  });
              }
          }
      })
  })
  .controller('QueriesCtrl', function(allTemplates, UserQuery) {
      var vm = this;
      vm.queries = allTemplates;
      vm.goToUrl = function(index, data) {
          var processedUrl = UserQuery.process(data, vm.queryTyped[index]);
          UserQuery.goToUrl(processedUrl);
      };
  });
  </code></pre>
  
  <p>When trying to run tests I get the error</p>
  
  <pre><code>Unknown provider: allTemplatesProvider &lt;- allTemplates &lt;- QueriesCtrl
  </code></pre>
  
  <p>I've tried creating a spy and injecting it, but this does not work. Here's my test at the moment:</p>
  
  <pre><code>describe('Unit: queriesCtrl', function() {
      var controller,
          scope,
          UserQuery;
  
      beforeEach(function() {
          module('myapp');
          inject(function($injector) {
              UserQuery = $injector.get('UserQuery');
              allTemplates = jasmine.createSpyObj('allTemplates', [{a:1}, {a:2}, {b:3}]);
          });
      });
  
      describe('goToUrl', function() {
          beforeEach(inject(function ($rootScope, $controller) {
              scope = $rootScope.$new();
              controller = $controller('QueriesCtrl as ctrl', {
                  '$scope': scope
              });
          }));
          it('should call UserQuery.process()', function() {
              spyOn(UserQuery, 'process');
              scope.ctrl.goToUrl();
              expect(UserQuery.process).toHaveBeenCalled();
          });
      });
  });
  </code></pre>