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 // describe('Controller: WidgetDetailsModalCtrl', ()=> {
25 // beforeEach(module('testUtils'));
26 // beforeEach(module('ecompApp'));
28 // let promisesTestUtils;
29 // //destroy $http default cache before starting to prevent the error 'default cache already exists'
30 // //_promisesTestUtils_ comes from testUtils for promises resolve/reject
31 // beforeEach(inject((_CacheFactory_, _promisesTestUtils_)=> {
32 // _CacheFactory_.destroyAll();
33 // promisesTestUtils = _promisesTestUtils_;
36 // let widgetDetails, scope, $controller, $q, $rootScope, $log, widgetsService, errorMessageByCode, ECOMP_URL_REGEX;
37 // let deferredAdminApps, deferredUserProfile;
38 // let applicationsServiceMock, widgetsServiceMock, userProfileServiceMock;
39 // beforeEach(inject((_$controller_, _$q_, _$rootScope_, _$log_)=> {
40 // [$controller, $q, $rootScope, $log] = [_$controller_, _$q_, _$rootScope_, _$log_];
42 // deferredAdminApps = $q.defer();
43 // deferredUserProfile = $q.defer();
44 // /*applicationsServiceMock = {
45 // getAppsForSuperAdminAndAccountAdmin: () => {
46 // var promise = () => {return deferredAdminApps.promise};
47 // var cancel = jasmine.createSpy();
55 // widgetsServiceMock = {
56 // updateWidget: () => {
57 // var promise = () => {return deferredAdminApps.promise};
58 // var cancel = jasmine.createSpy();
64 // createWidget: () => {
65 // var promise = () => {return deferredAdminApps.promise};
66 // var cancel = jasmine.createSpy();
74 // userProfileServiceMock = jasmine.createSpyObj('userProfileServiceMock',['getUserProfile']);
75 // userProfileServiceMock.getUserProfile.and.returnValue(deferredUserProfile.promise);
77 // applicationsServiceMock = jasmine.createSpyObj('applicationsServiceMock',['getAppsForSuperAdminAndAccountAdmin']);
78 // applicationsServiceMock.getAppsForSuperAdminAndAccountAdmin.and.returnValue(deferredAdminApps.promise);
83 // errorMessageByCode = [];
84 // ECOMP_URL_REGEX = "";
85 // scope = $rootScope.$new();
86 // createController(scope);
89 // let createController = scopeObj => {
90 // widgetDetails = $controller('WidgetDetailsModalCtrl', {
93 // applicationsService: applicationsServiceMock,
94 // widgetsService: widgetsServiceMock,
95 // errorMessageByCode: errorMessageByCode,
96 // ECOMP_URL_REGEX: ECOMP_URL_REGEX,
97 // userProfileService: userProfileServiceMock
104 // let newWidgetModel = {
112 // let exsistingWidget = {
113 // name: 'some widget',
115 // appName: 'APP NAME',
118 // url: 'http://a.com'
120 // let adminApps = [{id: 1, name: 'a'}, {id: 2, name: 'b'}];
125 // it('should initialize controller with new widget mode when opening the modal without selected widget', ()=> {
126 // expect(widgetDetails.widget).toEqual(newWidgetModel);
129 // it('should initialize controller with exsisting widget details when opening the modal with selected widget', ()=> {
130 // scope.ngDialogData = {
131 // widget: exsistingWidget
133 // createController(scope);
134 // expect(widgetDetails.widget).toEqual(exsistingWidget);
137 // it('should populate widget selected app name and id when initializing controller with widget', () =>{
138 // deferredAdminApps.resolve(adminApps);
139 // scope.ngDialogData = {
140 // widget: exsistingWidget
142 // createController(scope);
144 // expect(widgetDetails.widget.appId).toEqual(adminApps[0].id);
145 // expect(widgetDetails.widget.appName).toEqual(adminApps[0].name);
149 // //save changes fail - conflict handling
150 // //save changes success