title: Angular Testing - Trouble mocking Service with $http dependency
body: <p>I'm trying to test a controller with a custom service dependency.  The service has a dependency on $http.  In my controller, I'm making reference to the "then" part of the promise, but that is making the test code blow up.  How are you supposed to mock a service and test a controller dependent on it?  <a href="http://plnkr.co/edit/ffiOB73gMawDqJ0a4tis?p=preview" rel="nofollow">Here's a plunker with the whole debacle.</a>  My service looks like this:</p>
  
  <pre><code>  app.service('FooService', ['$http', function($http){
      return {
        getFoo: function(){
          return $http.get('Foo');
        },
        getBar: function(){
          return 'bar';
        }
      };
    }]);
  </code></pre>
  
  <p>The controller:</p>
  
  <pre><code>  app.controller('FooController', ['$scope', 'FooService', function(scope, FooService){
      scope.hi = function() {};
  
      scope.getFoo = function(){
        FooService.getFoo().then(function(data){
          scope.bar = data.data;
        });
      };
  
      scope.getBar = function(){
        scope.bar = FooService.getBar();
      };
    }]);
  </code></pre>
  
  <p>In my understanding, the $http dependency should not be on the controller in order to drive testability and separation of concerns.  However, now I'm having trouble with the promise...  How should this be done properly?</p>