Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 1 | (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 | |
Matteo Scandolo | d02ef50 | 2016-04-27 15:58:16 -0700 | [diff] [blame] | 35 | it('should not add column if already present', () => { |
| 36 | expect(service.format('myWeird_String:')).toEqual('My weird string:'); |
| 37 | }); |
| 38 | |
Matteo Scandolo | c49f53c | 2016-04-20 11:38:42 -0700 | [diff] [blame] | 39 | }); |
| 40 | }); |
| 41 | |
| 42 | })(); |