Jasmine – TypeError: undefined is not a constructor

I have an directive for displaying tooltip like follow:

angular.module('cui.directives.cuiEllipsisTooltip', [])
  .directive('cuiEllipsisTooltip', ['$compile', '$timeout',
    function($compile, $timeout) {
      'use strict';

      return {
        restrict: 'A',
        scope: true,
        link: function(scope, element, attrs) {
          var raw = element[0];
          var hasTooltip = false;
          var leaveEventPromise = null;

          element.on('mouseenter', function() {
            if (raw.offsetWidth < raw.scrollWidth) {
              if (hasTooltip) {
                scope.enabled = true;
              } else {
                scope.tooltip = element.text();
                scope.enabled = true;

                element.attr('data-toggle', 'tooltip')
                  .attr('data-original-title', scope.tooltip)
                  .removeAttr('cui-ellipsis-tooltip');

                $compile(element)(scope);

                hasTooltip = true;

                element.tooltip('show');

                $timeout(function() {
                  element.trigger('mouseenter');
                });
              }

              leaveEventPromise = null;
            } else {
              scope.enabled = false;
            }
          });

          element.on('mouseleave', function() {
            element.tooltip('hide');
            if (leaveEventPromise === null) {
              leaveEventPromise = $timeout(function() {
                element.trigger('mouseleave');
              }, 50);
            }
          });

          scope.$watch(function() {
            return element.text();
          }, function(newVal, oldVal) {
            if (newVal !== oldVal) {
              scope.tooltip = newVal;
            }
          });
        }
      };
    }
  ]);

and I write a unit test to test the directive as below:

it('should show tooltip when the text is truncated', function() {
  // Given
  var text = 'testestestestestestestestestest';
  element = angular.element('<div cui-ellipsis-tooltip style="width: 30px;">' + text + '</div>');
  element.appendTo(document.body);
  $compile(element)($scope);
  $scope.$digest();

  // When
  element.trigger('mouseenter');
  // $timeout.flush();

  // Then
  var tooltip = element.next();
  expect(tooltip.length).toBe(1);
  expect(tooltip.hasClass('tooltip')).toBe(true);
  expect(tooltip.text().trim()).toEqual(text);
});

It gives me the error

TypeError: undefined is not a constructor (evaluating 'element.tooltip('show')').

I search on StackOverflow and found that this error occurs when you try to call a function that is not defined. So this function tooltip('show') of JQuery is not recognized by Karma-Jasmine. What should I do?

Source: AngularJS