blob: 9e6f519aea1b0a8731aa0f02b3c9ad2ae4fddde5 [file] [log] [blame]
Matteo Scandoloa4a47112016-12-16 10:06:13 -08001import * as angular from 'angular';
2import 'angular-mocks';
3import 'angular-ui-router';
4import {xosCore} from '../index';
5import {IXosPageTitleService} from './page-title';
6import IWindowService = angular.IWindowService;
Matteo Scandoloa4a47112016-12-16 10:06:13 -08007
8let service: IXosPageTitleService, $window: IWindowService;
Matteo Scandolo828d1e82017-01-17 14:49:38 -08009
10const MockStyleConfig = {
11 projectName: 'CORD'
12};
13
Matteo Scandoloa4a47112016-12-16 10:06:13 -080014describe('The PageTitle service', () => {
15
Matteo Scandolo828d1e82017-01-17 14:49:38 -080016 beforeEach(() => {
17 angular.module(xosCore)
18 .constant('StyleConfig', MockStyleConfig);
19 angular.mock.module(xosCore);
20 });
Matteo Scandoloa4a47112016-12-16 10:06:13 -080021
22 beforeEach(angular.mock.inject((
23 PageTitle: IXosPageTitleService,
24 _$window_: IWindowService
25 ) => {
26 service = PageTitle;
27 $window = _$window_;
28 }));
29
30 it('should get the page title', () => {
31 $window.document.title = 'test';
32 expect(service.get()).toEqual('test');
33 });
34
35 it('should set a page title', () => {
36 service.set('sample');
Matteo Scandolo828d1e82017-01-17 14:49:38 -080037 expect($window.document.title).toEqual(`${MockStyleConfig.projectName} - sample`);
Matteo Scandoloa4a47112016-12-16 10:06:13 -080038 });
Matteo Scandoloee655a12016-12-19 15:38:43 -080039
40 it('should convert dots to >', () => {
41 service.set('core.sample.bread.crumb');
Matteo Scandolo828d1e82017-01-17 14:49:38 -080042 expect($window.document.title).toEqual(`${MockStyleConfig.projectName} - core > sample > bread > crumb`);
Matteo Scandoloee655a12016-12-19 15:38:43 -080043 });
Matteo Scandoloa4a47112016-12-16 10:06:13 -080044});