title: How to unit test a key press event in angular directive
body: <p>I've created an edit directive to wrap an html input in a fancy frame.</p>
  
  <p>Now I'm creating a unit test to check that once I type in the input the dirty state of the form controller is set.
  This is what I got so far but it fails on the 2nd expect. </p>
  
  <p>What's wrong here?</p>
  
  <p>Thanks in advance!</p>
  
  <pre><code>describe('dirty', function () {
      it('false', function () {
          var scope = $rootScope.$new(),
              form = $compile('&lt;form name="form"&gt;&lt;edit ng-model="model"&gt;&lt;/edit&gt;&lt;/form&gt;')(scope),
              input = form.find('input');
          scope.$digest();
          expect(scope.form.$dirty).toBeFalsy();
          input.triggerHandler('keydown', { which: 65 });
          expect(scope.form.$dirty).toBeTruthy();
      });
  });
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>For all that matters it comes down to this <a href="http://plnkr.co/edit/aoPos8WNlwGlaQKrRLaY">plunker</a> (no jQuery) ... or <a href="http://plnkr.co/edit/oeZeyq2i0KEPcyvGqWqT?p=preview">this</a> one using jQuery</p>
  
  <p>Any idea?</p>