import commonModule from '../';

describe('remove salutation filter', () => {
  beforeEach(angular.mock.module(commonModule));

  describe('with Salutation not containing period', () => {
    it('should remove salutation', angular.mock.inject(($filter) => {
      const name = 'Sir Schmoopy of Awesometon';
      const sut = $filter('removeSalutation')(name);
      expect(sut).toEqual('Schmoopy of Awesometon');
    }));

    it('should ignore case', angular.mock.inject(($filter) => {
      const name = 'sir Schmoopy of Awesometon';
      const sut = $filter('removeSalutation')(name);
      expect(sut).toEqual('Schmoopy of Awesometon');
    }));

    it('should ignore leading white space', angular.mock.inject(($filter) => {
      const name = '   sir Schmoopy of Awesometon';
      const sut = $filter('removeSalutation')(name);
      expect(sut).toEqual('Schmoopy of Awesometon');
    }));

    it('should maintain intermediate white space', angular.mock.inject(($filter) => {
      const name = 'sir   Schmoopy of Awesometon';
      const sut = $filter('removeSalutation')(name);
      expect(sut).toEqual('  Schmoopy of Awesometon');
    }));
  });

  describe('with Salutation containing period', () => {
    it('should remove salutation', angular.mock.inject(($filter) => {
      const name = 'Dr. Sigmund Freud';
      const sut = $filter('removeSalutation')(name);
      expect(sut).toEqual('Sigmund Freud');
    }));
  });

  describe('without a Salutation', () => {
    it('should leave the name unaltered', angular.mock.inject(($filter) => {
      const name = 'Steve Smith';
      const sut = $filter('removeSalutation')(name);
      expect(sut).toEqual(name);
    }));
  });
});
