all files / src/app/components/common/ Logo.spec.js

100% Statements 22/22
100% Branches 0/0
100% Functions 5/5
100% Lines 22/22
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 28 29 30 31 32 33 34 35 36 37                             
import angular from 'angular';
import 'angular-mocks';
import {Logo} from './Logo';
 
describe('Logo component', () => {
  beforeEach(() => {
    angular
      .module('logo', ['app/components/common/Logo.html'])
      .component('logo', Logo);
    angular.mock.module('logo');
  });
 
  it('should render correctly', angular.mock.inject(($rootScope, $compile) => {
    const $scope = $rootScope.$new();
    const element = $compile('<logo></logo>')($scope);
    $scope.$digest();
    expect(element.find('img').length).toEqual(1);
  }));
 
  it('should bind a link property', angular.mock.inject($componentController => {
    const bindings = {link: true};
    let component = $componentController('logo', {}, bindings);
    expect(component.link).toBe(true);
    bindings.link = false;
    component = $componentController('logo', {}, bindings);
    expect(component.link).toBe(false);
  }));
 
  it('should render a linked logo', angular.mock.inject(($rootScope, $compile) => {
    const $scope = $rootScope.$new();
    const element = $compile('<logo link="true"></logo>')($scope);
    $scope.$digest();
    const a = element.find('a');
    expect(a.attr('ui-sref')).toEqual('app');
  }));
});