       element = $compile("<mac-tag-autocomplete mac-tag-autocomplete-selected='selected' mac-tag-autocomplete-on-keydown='keydown()'></mac-tag-autocomplete>") $rootScope
       $rootScope.$digest()
 
-      textInput = $(".mac-autocomplete", element)
-      textInput.trigger $.Event("keydown", which: keys.BACKSPACE)
+      textInput = element[0].querySelector ".mac-autocomplete"
+      angular.element(textInput).triggerHandler
+        type:  "keydown"
+        which: keys.BACKSPACE
 
       expect($rootScope.selected.length).toBe 0
 

      $rootScope.$digest()
      $timeout.flush()

      textInput = $(".mac-autocomplete", element)
      textInput.trigger "keyup", keyCode: keys.A

      expect($rootScope.keyup).toHaveBeenCalled()


      element = $compile("<mac-tag-autocomplete mac-tag-autocomplete-url='url'></mac-tag-autocomplete>") $rootScope
      $rootScope.$digest()

      textInput = element[0].querySelector ".mac-autocomplete"
      expect(textInput.getAttribute("mac-autocomplete-url")).toBe "url"

    it "should set the source attribute on mac-autocomplete", ->
      $rootScope.source = ["test", "test1", "test2"]
      element = $compile("<mac-tag-autocomplete mac-tag-autocomplete-source='source'></mac-tag-autocomplete>") $rootScope
      $rootScope.$digest()

      textInput = element[0].querySelector ".mac-autocomplete"
      expect(textInput.getAttribute("mac-autocomplete-source")).toBe "autocompleteSource"

    it "should have the same source function as the parent scope", ->
      $rootScope.source = jasmine.createSpy "source"
