'use strict';

import commonModule from '..';

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

  describe('all lower case', () => {
    it('should upcase only the first letter of each word', angular.mock.inject(($filter) => {
      const str = 'hello world';
      const sut = $filter('titleCase')(str);
      expect(sut).toEqual('Hello World');
    }));
  });

  describe('all upper case', () => {
    it('should downcase all but the first letter of each word', angular.mock.inject(($filter) => {
      const str = 'HELLO WORLD';
      const sut = $filter('titleCase')(str);
      expect(sut).toEqual('Hello World');
    }));
  });

  describe('random casing', () => {
    it('should downcase all but the first letter of each word', angular.mock.inject(($filter) => {
      const str = 'HeLLo wOrLd';
      const sut = $filter('titleCase')(str);
      expect(sut).toEqual('Hello World');
    }));
  });

  describe('with numbers', () => {
    it('should downcase all but the first letter of each word', angular.mock.inject(($filter) => {
      const str = 'HeLLo wOrLd123';
      const sut = $filter('titleCase')(str);
      expect(sut).toEqual('Hello World123');
    }));
  });

  describe('empty string', () => {
    it('should return empty string', angular.mock.inject(($filter) => {
      const str = '';
      const sut = $filter('titleCase')(str);
      expect(sut).toEqual('');
    }));
  });

  describe('undefined', () => {
    it('should return undefined', angular.mock.inject(($filter) => {
      let str;
      const sut = $filter('titleCase')(str);
      expect(sut).toBeUndefined();
    }));
  });
});
