blob: 119f4ce5471e119c58b89c815ded09ac2e00d5e8 [file] [log] [blame]
Matteo Scandoloa5d03d52016-07-21 11:35:46 -07001(function () {
2 'use strict';
3
4 describe('The xos.helper module', function(){
5 describe('The label formatter service', () => {
6
7 let service;
8
9 // load the application module
10 beforeEach(module('xos.helpers'));
11
12 // inject the cartService
13 beforeEach(inject(function (_LabelFormatter_) {
14 // The injector unwraps the underscores (_) from around the parameter names when matching
15 service = _LabelFormatter_;
16 }));
17
18 it('should replace underscores in a string', () => {
19 expect(service._formatByUnderscore('my_test')).toEqual('my test');
20 expect(service._formatByUnderscore('_test')).toEqual('test');
21 });
22
23 it('should split a camel case string', () => {
24 expect(service._formatByUppercase('myTest')).toEqual('my test');
25 });
26
27 it('should capitalize a string', () => {
28 expect(service._capitalize('my test')).toEqual('My test');
29 });
30
31 it('should format an object property to a label', () => {
32 expect(service.format('myWeird_String')).toEqual('My weird string:');
33 });
34
35 it('should not add column if already present', () => {
36 expect(service.format('myWeird_String:')).toEqual('My weird string:');
37 });
38
39 });
40 });
41
42})();