title: unit test spy on $emit
body: <p>I'm trying to spy on an $emit from a directive, but somehow I cannot get the spy to 'hear' the $emit.</p>
  
  <p>This is the code in my directives' controller:</p>
  
  <pre><code>$scope.$on('send', function () {
      console.log('called');
      $scope.$emit('resultSend', {'ok': true, 'data': ''});
  });
  </code></pre>
  
  <p>This is my unit test:</p>
  
  <pre><code>var $rootScope, $compile, elm, element;
  
  beforeEach(inject(function ($injector) {
      $rootScope = $injector.get('$rootScope');
      $compile = $injector.get('$compile');
      elm = angular.element('&lt;test&gt;&lt;/test&gt;');
      element = $compile(elm)($rootScope);
  }));
  
  
  it('should listen for the send broadcast and emit the resultSend', function () {
      spyOn($rootScope, '$emit');
      $rootScope.$broadcast('send');
      expect($rootScope.$emit).toHaveBeenCalledWith('resultSend');
  });
  </code></pre>
  
  <p>The console.log output ('called') is printed out by Karma, so I guess the unit test broadcast event does work.</p>
  
  <p>Does this have to do with $emit not broadcasting down but up, and if so, how do I catch it, and if not, how else do I handle this case?</p>