all files / src/app/utils/ external-link.directive.spec.js

100% Statements 11/11
100% Branches 0/0
100% Functions 5/5
100% Lines 11/11
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27                               
import angular from 'angular';
import 'angular-mocks';
import directive from './external-link.directive';
 
describe('External link directive', () => {
  let $scope;
  let element;
 
  beforeEach(() => {
    angular.module('linkDirective', [])
      .directive('externalLink', directive);
    angular.mock.module('linkDirective');
    angular.mock.inject(($rootScope, $compile) => {
      $scope = $rootScope.$new();
      element = $compile('<span external-link="http://example.com">Inner Text</span>')($scope);
    });
  });
 
  it('should append a link to element', () => {
    expect(element.find('a').length).toEqual(1);
  });
 
  it('should add a relative class to element', () => {
    expect(element.hasClass('relative')).toBe(true);
  });
});