[PORTAL-16 PORTAL-18] Widget ms; staging
[portal.git] / ecomp-portal-FE-common / client / app / views / users / users.controller.spec.js
1 /*-
2  * ================================================================================
3  * ECOMP Portal
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ================================================================================
19  */
20 // /**
21 //  * Created by nnaffar on 12/17/15.
22 //  */
23 // 'use strict';
24 //
25 // describe('Controller: UsersCtrl ', () => {
26 //     beforeEach(module('ecompApp'));
27 //
28 //     //destroy $http default cache before starting to prevent the error 'default cache already exists'
29 //     beforeEach(inject((_CacheFactory_)=> {
30 //         _CacheFactory_.destroyAll();
31 //     }));
32 //
33 //     let users, $controller, $q, $rootScope, $log, $scope;
34 //
35 //     beforeEach(inject((_$controller_, _$q_, _$rootScope_, _$log_)=> {
36 //         [$controller, $q, $rootScope, $log] = [_$controller_, _$q_, _$rootScope_, _$log_];
37 //     }));
38 //
39 //     let applicationsServiceMock, usersServiceMock;
40 //     let deferredAdminApps, deferredUsersAccounts;
41 //     beforeEach(()=> {
42 //         [deferredAdminApps, deferredUsersAccounts] = [$q.defer(), $q.defer()];
43 //
44 //         applicationsServiceMock = {
45 //             getAdminApps: () => {
46 //                 var promise = () => {return deferredAdminApps.promise};
47 //                 var cancel = jasmine.createSpy();
48 //                 return {
49 //                     promise: promise,
50 //                     cancel: cancel
51 //                 }
52 //             }
53 //         };
54 //
55 //         usersServiceMock = jasmine.createSpyObj('usersServiceMock', ['getAccountUsers']);
56 //
57 //         //applicationsServiceMock.getAdminApps().promise().and.returnValue(deferredAdminApps.promise);
58 //         usersServiceMock.getAccountUsers.and.returnValue(deferredUsersAccounts.promise);
59 //
60 //         $scope = $rootScope.$new();
61 //         users = $controller('UsersCtrl', {
62 //             $log: $log,
63 //             applicationsService: applicationsServiceMock,
64 //             usersService: usersServiceMock,
65 //             $scope: $scope
66 //         });
67 //         $scope.users = users;
68 //     });
69 //
70 //     //MOCKS
71 //     let appsListMock = [
72 //         {value: 'SSP', title: 'SSP', id: 3},
73 //         {value: 'ASDC', title: 'ASDC', id: 23},
74 //         {value: 'Formation', title: 'Formation', id: 223}
75 //     ];
76 //
77 //     let usersListMock = [
78 //         {
79 //             "orgUserId": "nn605g",
80 //             "firstName": "Nabil",
81 //             "lastName": "Naffar",
82 //             "roles": [
83 //                 {
84 //                     "roleId": 1,
85 //                     "roleName": "Standard user"
86 //                 },
87 //                 {
88 //                     "roleId": 9,
89 //                     "roleName": "Super standard user"
90 //                 },
91 //                 {
92 //                     "roleId": 2,
93 //                     "roleName": "Super duper standard user"
94 //                 }
95 //             ]
96 //         }];
97 //     let secondUsersListMock = [
98 //         {
99 //             "orgUserId": "sadf7",
100 //             "firstName": "John",
101 //             "lastName": "Hall",
102 //             "roles": [
103 //                 {
104 //                     "roleId": 1,
105 //                     "roleName": "Standard user"
106 //                 },
107 //                 {
108 //                     "roleId": 2,
109 //                     "roleName": "Super duper standard user"
110 //                 }
111 //             ]
112 //         }];
113 //
114 //     it('should get all user\'s administrated applications when initializing the view', ()=> {
115 //         deferredAdminApps.resolve(appsListMock);
116 //         deferredUsersAccounts.resolve(usersListMock);
117 //         $scope.$apply();
118 //         expect(users.adminApps).toEqual(appsListMock);
119 //         expect(users.selectedApp).toEqual(appsListMock[0]);
120 //     });
121 //
122 //     it('should get first application users by default when initializing the view', () => {
123 //         $scope.$apply();
124 //         deferredAdminApps.resolve(appsListMock);
125 //         deferredUsersAccounts.resolve(usersListMock);
126 //         $scope.$apply();
127 //         expect(users.accountUsers).toEqual(usersListMock);
128 //     });
129 //
130 //     it('should get application users when changing application', () => {
131 //         $scope.$apply();
132 //         deferredAdminApps.resolve(appsListMock);
133 //         $scope.$apply();
134 //
135 //         users.selectedApp = appsListMock[1];
136 //         deferredUsersAccounts.resolve(secondUsersListMock);
137 //         $scope.$apply('users');//change app
138 //
139 //         expect(users.accountUsers).toEqual(secondUsersListMock);
140 //     });
141 // });