| import * as angular from 'angular'; |
| import 'angular-mocks'; |
| import 'angular-ui-router'; |
| |
| import {IXosConfigHelpersService} from './config.helpers'; |
| import {xosCore} from '../../index'; |
| |
| let service: IXosConfigHelpersService; |
| describe('The ConfigHelpers service', () => { |
| |
| beforeEach(angular.mock.module(xosCore)); |
| |
| beforeEach(angular.mock.inject(( |
| ConfigHelpers: IXosConfigHelpersService, |
| ) => { |
| service = ConfigHelpers; |
| })); |
| |
| describe('The pluralize function', () => { |
| it('should pluralize string', () => { |
| expect(service.pluralize('test')).toEqual('tests'); |
| expect(service.pluralize('test', 1)).toEqual('test'); |
| expect(service.pluralize('xos')).toEqual('xosses'); |
| expect(service.pluralize('slice')).toEqual('slices'); |
| }); |
| |
| it('should preprend count to string', () => { |
| expect(service.pluralize('test', 6, true)).toEqual('6 tests'); |
| expect(service.pluralize('test', 1, true)).toEqual('1 test'); |
| }); |
| }); |
| |
| describe('the label formatter', () => { |
| it('should format a camel case string', () => { |
| expect(service.toLabel('camelCase')).toEqual('Camel case'); |
| }); |
| |
| it('should format a snake case string', () => { |
| expect(service.toLabel('snake_case')).toEqual('Snake case'); |
| }); |
| |
| it('should format a kebab case string', () => { |
| expect(service.toLabel('kebab-case')).toEqual('Kebab case'); |
| }); |
| |
| it('should set plural', () => { |
| expect(service.toLabel('kebab-case', true)).toEqual('Kebab cases'); |
| }); |
| |
| it('should format an array of strings', () => { |
| let strings: string[] = ['camelCase', 'snake_case', 'kebab-case']; |
| let labels = ['Camel case', 'Snake case', 'Kebab case']; |
| expect(service.toLabels(strings)).toEqual(labels); |
| }); |
| |
| it('should set plural on an array of strings', () => { |
| let strings: string[] = ['camelCase', 'snake_case', 'kebab-case']; |
| let labels = ['Camel cases', 'Snake cases', 'Kebab cases']; |
| expect(service.toLabels(strings, true)).toEqual(labels); |
| }); |
| }); |
| |
| }); |