2 * ================================================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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 * ================================================================================
21 // * Created by nnaffar on 12/17/15.
25 // describe('Controller: UsersCtrl ', () => {
26 // beforeEach(module('ecompApp'));
28 // //destroy $http default cache before starting to prevent the error 'default cache already exists'
29 // beforeEach(inject((_CacheFactory_)=> {
30 // _CacheFactory_.destroyAll();
33 // let users, $controller, $q, $rootScope, $log, $scope;
35 // beforeEach(inject((_$controller_, _$q_, _$rootScope_, _$log_)=> {
36 // [$controller, $q, $rootScope, $log] = [_$controller_, _$q_, _$rootScope_, _$log_];
39 // let applicationsServiceMock, usersServiceMock;
40 // let deferredAdminApps, deferredUsersAccounts;
42 // [deferredAdminApps, deferredUsersAccounts] = [$q.defer(), $q.defer()];
44 // applicationsServiceMock = {
45 // getAdminApps: () => {
46 // var promise = () => {return deferredAdminApps.promise};
47 // var cancel = jasmine.createSpy();
55 // usersServiceMock = jasmine.createSpyObj('usersServiceMock', ['getAccountUsers']);
57 // //applicationsServiceMock.getAdminApps().promise().and.returnValue(deferredAdminApps.promise);
58 // usersServiceMock.getAccountUsers.and.returnValue(deferredUsersAccounts.promise);
60 // $scope = $rootScope.$new();
61 // users = $controller('UsersCtrl', {
63 // applicationsService: applicationsServiceMock,
64 // usersService: usersServiceMock,
67 // $scope.users = users;
71 // let appsListMock = [
72 // {value: 'SSP', title: 'SSP', id: 3},
73 // {value: 'ASDC', title: 'ASDC', id: 23},
74 // {value: 'Formation', title: 'Formation', id: 223}
77 // let usersListMock = [
79 // "orgUserId": "nn605g",
80 // "firstName": "Nabil",
81 // "lastName": "Naffar",
85 // "roleName": "Standard user"
89 // "roleName": "Super standard user"
93 // "roleName": "Super duper standard user"
97 // let secondUsersListMock = [
99 // "orgUserId": "sadf7",
100 // "firstName": "John",
101 // "lastName": "Hall",
105 // "roleName": "Standard user"
109 // "roleName": "Super duper standard user"
114 // it('should get all user\'s administrated applications when initializing the view', ()=> {
115 // deferredAdminApps.resolve(appsListMock);
116 // deferredUsersAccounts.resolve(usersListMock);
118 // expect(users.adminApps).toEqual(appsListMock);
119 // expect(users.selectedApp).toEqual(appsListMock[0]);
122 // it('should get first application users by default when initializing the view', () => {
124 // deferredAdminApps.resolve(appsListMock);
125 // deferredUsersAccounts.resolve(usersListMock);
127 // expect(users.accountUsers).toEqual(usersListMock);
130 // it('should get application users when changing application', () => {
132 // deferredAdminApps.resolve(appsListMock);
135 // users.selectedApp = appsListMock[1];
136 // deferredUsersAccounts.resolve(secondUsersListMock);
137 // $scope.$apply('users');//change app
139 // expect(users.accountUsers).toEqual(secondUsersListMock);