Matteo Scandolo | a4a4711 | 2016-12-16 10:06:13 -0800 | [diff] [blame] | 1 | import * as angular from 'angular'; |
| 2 | import 'angular-mocks'; |
| 3 | import 'angular-ui-router'; |
| 4 | import {xosCore} from '../index'; |
| 5 | import {IXosPageTitleService} from './page-title'; |
| 6 | import IWindowService = angular.IWindowService; |
| 7 | import {StyleConfig} from '../../config/style.config'; |
| 8 | |
| 9 | let service: IXosPageTitleService, $window: IWindowService; |
| 10 | describe('The PageTitle service', () => { |
| 11 | |
| 12 | beforeEach(angular.mock.module(xosCore)); |
| 13 | |
| 14 | beforeEach(angular.mock.inject(( |
| 15 | PageTitle: IXosPageTitleService, |
| 16 | _$window_: IWindowService |
| 17 | ) => { |
| 18 | service = PageTitle; |
| 19 | $window = _$window_; |
| 20 | })); |
| 21 | |
| 22 | it('should get the page title', () => { |
| 23 | $window.document.title = 'test'; |
| 24 | expect(service.get()).toEqual('test'); |
| 25 | }); |
| 26 | |
| 27 | it('should set a page title', () => { |
| 28 | service.set('sample'); |
| 29 | expect($window.document.title).toEqual(`${StyleConfig.projectName} - sample`); |
| 30 | }); |
Matteo Scandolo | ee655a1 | 2016-12-19 15:38:43 -0800 | [diff] [blame] | 31 | |
| 32 | it('should convert dots to >', () => { |
| 33 | service.set('core.sample.bread.crumb'); |
| 34 | expect($window.document.title).toEqual(`${StyleConfig.projectName} - core > sample > bread > crumb`); |
| 35 | }); |
Matteo Scandolo | a4a4711 | 2016-12-16 10:06:13 -0800 | [diff] [blame] | 36 | }); |