title: AngularJS directive link function not called in jasmine test
body: <p>I'm creating an element directive that calls a service in its <code>link</code> function:</p>
  
  <pre><code>app.directive('depositList', ['depositService', function (depositService) {
      return {
          templateUrl: 'depositList.html',
          restrict: 'E',
          scope: {
              status: '@status',
              title: '@title'
          },
          link: function (scope) {
              scope.depositsInfo = depositService.getDeposits({
                  status: scope.status
              });
          }
      };
  }]);
  </code></pre>
  
  <p>The service is trivial for now:</p>
  
  <pre><code>app.factory('depositService', function(){
    return {
      getDeposits: function(criteria){
        return 'you searched for : ' + criteria.status;
      }
    };
  });
  </code></pre>
  
  <p>I am trying to write a test that ensures that the <code>depositService.getDeposits()</code> is called with the correct status value.</p>
  
  <pre><code>describe('Testing the directive', function() {
    beforeEach(module('plunker'));
    it('should query for pending deposits', inject(function ($rootScope, $compile, $httpBackend, depositService) {
  
        spyOn(depositService, 'getDeposits').and.callFake(function(criteria){ 
          return 'blah'; 
        });
  
        $httpBackend.when('GET', 'depositList.html')
            .respond('&lt;div&gt;&lt;/div&gt;');
  
        var elementString = '&lt;deposit-list status="pending" title="blah"&gt;&lt;/deposit-list&gt;';
        var element = angular.element(elementString);
        var scope = $rootScope.$new();
        $compile(element)(scope);
        scope.$digest();
  
        var times = depositService.getDeposits.calls.all().length;
        expect(times).toBe(1);
    }));
  });
  </code></pre>
  
  <p>The test fails because times === 0. This code runs fine in the browser, but in the test the <code>link</code> function and the service never seem to be called. Any thoughts?</p>
  
  <p>plunker: <a href="http://plnkr.co/edit/69jK8c">http://plnkr.co/edit/69jK8c</a></p>