Assign image keyname and pubkey at vnf level
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / apps / dlux / dlux-web / src / common / navigation / navigation.spec.js
1 define(['common/navigation/navigation.module', 'angular-ui-router',], function () {
2   describe('Navigation Module', function () {
3     var scope, NavHelperMock, EventMock, controller;
4
5     beforeEach(angular.mock.module('ui.router'));
6     beforeEach(module('app.core', function ($provide) {
7       function NavHelperProvider() {
8         this.addToView = function (url) {};
9         this.addControllerUrl = function (url) {};
10         this.$get = function NavHelperFactory() {
11           return new NavHelperProvider();
12         };
13       }
14       $provide.provider('NavHelper', NavHelperProvider);
15     }));
16
17     beforeEach(module('app.common.nav'));
18
19     beforeEach(inject(function ($rootScope, $controller) {
20       scope = $rootScope.$new();
21       controller = $controller;
22
23       NavHelperMock = {
24         getMenu: function () {
25           return {
26             "id": "",
27             "title": "",
28             "active": "",
29             "submenu": ""
30           };
31         }
32       };
33
34       EventMock = {
35         stopPropagation: function () {
36           return null;
37         },
38         preventDefault: function () {
39           return null;
40         }
41       };
42
43     }));
44
45     it('Should have receive all menu items', function () {
46       spyOn(NavHelperMock, 'getMenu').andCallThrough();
47       controller('NavCtrl', {
48         $scope: scope,
49         NavHelper: NavHelperMock
50       });
51
52       expect(NavHelperMock.getMenu).toHaveBeenCalled();
53       expect(scope.navList).toBeDefined();
54     });
55
56     it('Should have create utility methods to show and hide submenu', function () {
57       controller('NavItemCtrl', {
58         $scope: scope,
59         NavHelper: NavHelperMock
60       });
61
62       expect(scope.display).toEqual('none');
63       expect(scope.isOpen).toBeFalsy();
64
65       expect(scope.isValid).toBeDefined();
66       expect(scope.updateTemplate).toBeDefined();
67     });
68
69     it('Should look if a item exist or not', function () {
70       controller('NavItemCtrl', {
71         $scope: scope,
72         NavHelper: NavHelperMock
73       });
74       var item = {};
75
76       expect(scope.isValid(item)).toBeTruthy();
77       expect(scope.isValid(null)).toBeFalsy();
78     });
79
80     it('Should toggle the status of the item scope', function () {
81       spyOn(EventMock, 'stopPropagation').andCallThrough();
82       spyOn(EventMock, 'preventDefault').andCallThrough();
83       controller('NavItemCtrl', {
84         $scope: scope,
85         NavHelper: NavHelperMock
86       });
87
88       var initOpen = scope.isOpen;
89       var initDisplay = scope.display;
90
91       scope.updateTemplate(EventMock, {});
92       expect(scope.isOpen).not.toEqual(initOpen);
93       expect(scope.display).not.toEqual(initDisplay);
94
95       scope.updateTemplate(EventMock, {});
96       expect(scope.isOpen).toEqual(initOpen);
97       expect(scope.display).toEqual(initDisplay);
98
99       expect(EventMock.stopPropagation.calls.length).toEqual(2);
100       expect(EventMock.preventDefault.calls.length).toEqual(2);
101     });
102   });
103 });