title: How can I test a controller with resolve properties in AngularJS?
body: <p>How can one test a controller with resolve properties?
  It throws an error: Unknown provider: InitProvider, during testing, understandably. 
  How can I test it?</p>
  
  <p>I use the init property in the route config to load data and pass it along to the controller at controller instantiation so the route doesn't change before data is loaded.</p>
  
  <pre><code>  $routeProvider
      .when('/topic/:topic_id/content/:content_id', {
        templateUrl: 'views/content.html',
        controller: 'ContentCtrl',
      resolve: {
        init: ContentCtrl.init
      }
      });
  </code></pre>
  
  <p>Is the pattern completely wrong in the first place?</p>
  
  <pre><code>'use strict';
  
  var ContentCtrl = ['$scope', '$location', '$routeParams', 'init', function ($scope, $location, $routeParams, init) {
  
      $scope.contents = init.contents;
  
    }];
  
  ContentCtrl.init = ['$q', 'app_config', '$log', '$timeout', function ($q, app_config, $log, $timeout) {
  
      var defer = $q.defer();
  
      $log.log("ContentCtrl loading..");
  
      $timeout(function() {
          defer.resolve({contents: [
                                      {message: 'Hello!'}
                                    ]});
  
          $log.log("ContentCtrl loaded.");
  
      }, 2000);
  
      return defer.promise;
  }];
  
  angular.module('studentportalenApp').controller('ContentCtrl', ContentCtrl);
  </code></pre>
  
  <p>I want to encapsulate the whole controller inside <code>.controler('ContentCtrl', function() { ... })</code>, but have yet to figure out how this is done correctly to make the init available in the route configuration.</p>