Added tests
Change-Id: I493675212f4b1548b32a6d92ce3664d184bc0e04
diff --git a/src/app/core/services/navigation.spec.ts b/src/app/core/services/navigation.spec.ts
new file mode 100644
index 0000000..1096ec7
--- /dev/null
+++ b/src/app/core/services/navigation.spec.ts
@@ -0,0 +1,47 @@
+import * as angular from 'angular';
+import 'angular-mocks';
+import 'angular-ui-router';
+import {xosCore} from '../index';
+import {IXosNavigationService, IXosNavigationRoute} from './navigation';
+
+let service: IXosNavigationService;
+
+const defaultRoutes: IXosNavigationRoute[] = [
+ {label: 'Home', state: 'xos.dashboard'}
+];
+
+describe('The Navigation service', () => {
+
+ beforeEach(angular.mock.module(xosCore));
+
+ beforeEach(angular.mock.inject((
+ NavigationService: IXosNavigationService,
+ ) => {
+ service = NavigationService;
+ }));
+
+ it('should return navigation routes', () => {
+ expect(service.query()).toEqual(defaultRoutes);
+ });
+
+ it('should add a route', () => {
+ const testRoutes: IXosNavigationRoute[] = [
+ {label: 'TestState', state: 'xos.test'},
+ {label: 'TestUrl', url: 'test'}
+ ];
+ service.add(testRoutes[0]);
+ service.add(testRoutes[1]);
+ expect(service.query()).toEqual(defaultRoutes.concat(testRoutes));
+ });
+
+ it('should not add route that have both url and state', () => {
+ function wrapper() {
+ service.add({
+ label: 'Fail',
+ url: 'f',
+ state: 'f'
+ });
+ }
+ expect(wrapper).toThrowError('[XosNavigation] You can\'t provide both state and url');
+ });
+});