title: AngularJS – how to write unit-test in Jasmine for enter events directive
body: <p>I have created <strong>enter event directive</strong> in <strong>AngularJS</strong>, so that i want to run test case for that directive. but i don't know how to write code for enter event.</p>
  
  <pre><code>describe('Unit Test: Enter Event', function() {
  var elm, compile, scope;    
  
  beforeEach(function() {
      module('att.sandbox.attEnterEvent');
      inject(function($compile, $rootScope) {
          compile = $compile;
          scope = $rootScope.$new();
      });
  });
  
  /*scenarion 1*/
  it("Enetr Key should call the method inside controller", function() {
      elm = angular.element('&lt;input type="text" att-enter-event="enterEvent()"&gt;');
      elm = compile(elm)(scope);
      scope.$digest();
      scope.enterEvent = jasmine.createSpy();
  
       //**Here i want to add enter event test case** 
  
       expect().toHaveBeenCalled();
  });
  })
  </code></pre>
  
  <p></p>