2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
36 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
39 // describe('Controller: WidgetDetailsModalCtrl', ()=> {
43 // beforeEach(module('testUtils'));
44 // beforeEach(module('ecompApp'));
46 // let promisesTestUtils;
47 // //destroy $http default cache before starting to prevent the error 'default cache already exists'
48 // //_promisesTestUtils_ comes from testUtils for promises resolve/reject
49 // beforeEach(inject((_CacheFactory_, _promisesTestUtils_)=> {
50 // _CacheFactory_.destroyAll();
51 // promisesTestUtils = _promisesTestUtils_;
54 // let widgetDetails, scope, $controller, $q, $rootScope, $log, widgetsService, errorMessageByCode, ECOMP_URL_REGEX;
55 // let deferredAdminApps, deferredUserProfile;
56 // let applicationsServiceMock, widgetsServiceMock, userProfileServiceMock;
57 // beforeEach(inject((_$controller_, _$q_, _$rootScope_, _$log_)=> {
58 // [$controller, $q, $rootScope, $log] = [_$controller_, _$q_, _$rootScope_, _$log_];
60 // deferredAdminApps = $q.defer();
61 // deferredUserProfile = $q.defer();
62 // /*applicationsServiceMock = {
63 // getAppsForSuperAdminAndAccountAdmin: () => {
64 // var promise = () => {return deferredAdminApps.promise};
65 // var cancel = jasmine.createSpy();
73 // widgetsServiceMock = {
74 // updateWidget: () => {
75 // var promise = () => {return deferredAdminApps.promise};
76 // var cancel = jasmine.createSpy();
82 // createWidget: () => {
83 // var promise = () => {return deferredAdminApps.promise};
84 // var cancel = jasmine.createSpy();
92 // userProfileServiceMock = jasmine.createSpyObj('userProfileServiceMock',['getUserProfile']);
93 // userProfileServiceMock.getUserProfile.and.returnValue(deferredUserProfile.promise);
95 // applicationsServiceMock = jasmine.createSpyObj('applicationsServiceMock',['getAppsForSuperAdminAndAccountAdmin']);
96 // applicationsServiceMock.getAppsForSuperAdminAndAccountAdmin.and.returnValue(deferredAdminApps.promise);
101 // errorMessageByCode = [];
102 // ECOMP_URL_REGEX = "";
103 // scope = $rootScope.$new();
104 // createController(scope);
107 // let createController = scopeObj => {
108 // widgetDetails = $controller('WidgetDetailsModalCtrl', {
111 // applicationsService: applicationsServiceMock,
112 // widgetsService: widgetsServiceMock,
113 // errorMessageByCode: errorMessageByCode,
114 // ECOMP_URL_REGEX: ECOMP_URL_REGEX,
115 // userProfileService: userProfileServiceMock
122 // let newWidgetModel = {
130 // let exsistingWidget = {
131 // name: 'some widget',
133 // appName: 'APP NAME',
136 // url: 'http://a.com'
138 // let adminApps = [{id: 1, name: 'a'}, {id: 2, name: 'b'}];
143 // it('should initialize controller with new widget mode when opening the modal without selected widget', ()=> {
144 // expect(widgetDetails.widget).toEqual(newWidgetModel);
147 // it('should initialize controller with exsisting widget details when opening the modal with selected widget', ()=> {
148 // scope.ngDialogData = {
149 // widget: exsistingWidget
151 // createController(scope);
152 // expect(widgetDetails.widget).toEqual(exsistingWidget);
155 // it('should populate widget selected app name and id when initializing controller with widget', () =>{
156 // deferredAdminApps.resolve(adminApps);
157 // scope.ngDialogData = {
158 // widget: exsistingWidget
160 // createController(scope);
162 // expect(widgetDetails.widget.appId).toEqual(adminApps[0].id);
163 // expect(widgetDetails.widget.appName).toEqual(adminApps[0].name);
167 // //save changes fail - conflict handling
168 // //save changes success