title: Can I get the textarea caret position in unit test with Jasmine?
body: <p>I am trying to implement '@ Users Feature' with angularjs, I almost finish the feature except writing an unit test. I have a Caret module which can help me get the caret position in textarea.</p>
  
  <p>I think the most important thing is to get the caret position but I dont know how to do it in jasmine.</p>
  
  <p>Mydirective</p>
  
  <pre><code>.directive('atUser', function (Caret) {
      return {
          restrict: 'A',
          link: function (scope, element) {
              element.bind('focus click keydown', function () {
                  scope.caretPos = Caret.getPos(element);
              });
  
              scope.$watch(function () {
                  return scope.caretPos;
              }, function (nowCaretPos) {
                  /* do something here */
              })
          }
      }
  })
  </code></pre>
  
  <p>Html</p>
  
  <pre><code>&lt;textarea ng-model="message" at-user&gt;&lt;/textarea&gt;
  </code></pre>
  
  <p>Jasmine</p>
  
  <pre><code>describe('test at user', function () {
      /* some init code */
      it('should get caret postion', function () {
          textarea = element.find('textarea');
          textarea.triggerHandler('focus');
          except(textarea.scope().caretPos).toEqual(0);
  
          /*
           * then i want to simulate keydown event and type something
           * and get the caret postion
           * but i dont know how to do it
           * /
      })
  })
  </code></pre>
  
  <p>One more thing is I dont want to use jquery.</p>
  
  <p>Can anyone help me?</p>
  
  <p>thanks a lot!</p>