2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 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============================================
39 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
41 import { ApplicationDetailsDialogComponent } from './application-details-dialog.component';
42 import { NgMaterialModule } from 'src/app/ng-material-module';
43 import { FormsModule } from '@angular/forms';
44 import { NgbActiveModal, NgbModal, NgbModule } from '@ng-bootstrap/ng-bootstrap';
45 import { HttpClientTestingModule } from '@angular/common/http/testing';
46 import { IApplications } from 'src/app/shared/model/applications-onboarding/applications';
47 import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
48 import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing';
49 import { NgbModalBackdrop } from '@ng-bootstrap/ng-bootstrap/modal/modal-backdrop';
50 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
51 import { InformationTooltipComponent } from '../../information-tooltip/information-tooltip.component';
52 import { MatTooltipModule } from '@angular/material';
53 import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
56 describe('ApplicationDetailsDialogComponent', () => {
57 let component: ApplicationDetailsDialogComponent;
58 let fixture: ComponentFixture<ApplicationDetailsDialogComponent>;
59 const applicationObj: IApplications = {"id":"testID"};
61 beforeEach(async(() => {
62 TestBed.configureTestingModule({
63 declarations: [ ApplicationDetailsDialogComponent,InformationModalComponent,ConfirmationModalComponent, InformationTooltipComponent],
64 imports: [NgMaterialModule,FormsModule,HttpClientTestingModule,NgbModule.forRoot(), MatTooltipModule],
65 providers: [NgbActiveModal],
66 schemas: [CUSTOM_ELEMENTS_SCHEMA]
67 }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent,ConfirmationModalComponent] } })
72 fixture = TestBed.createComponent(ApplicationDetailsDialogComponent);
73 component = fixture.componentInstance;
74 component.applicationObj = applicationObj;
75 fixture.detectChanges();
78 it('should create', () => {
79 expect(component).toBeTruthy();
81 it('removeImage should return stubbed value', () => {
82 spyOn(component, 'removeImage').and.callThrough();
83 component.removeImage();
84 expect(component.removeImage).toHaveBeenCalledWith();
86 it('saveChanges should return stubbed value', () => {
87 component.applicationObj.rolesInAAF = true;
88 component.applicationObj.isEnabled = false;
89 spyOn(component, 'saveChanges').and.callThrough();
90 component.saveChanges();
91 expect(component.saveChanges).toHaveBeenCalledWith();
92 component.applicationObj.isEnabled = true;
93 component.applicationObj.landingPage = 'www.test.com'
94 component.applicationObj.restrictedApp =true;
96 //spyOn(component, 'saveChanges').and.callThrough();
97 component.saveChanges();
98 expect(component.saveChanges).toHaveBeenCalledWith();
99 component.applicationObj.rolesInAAF = false;
100 component.applicationObj.landingPage = 'test'
101 component.applicationObj.restrictedApp =false;
102 component.applicationObj.isOpen = true;
103 component.isEditMode =true;
104 //spyOn(component, 'saveChanges').and.callThrough();
105 component.saveChanges();
106 expect(component.saveChanges).toHaveBeenCalledWith();
108 it('saveChanges Central Auth is disabled', () => {
109 component.applicationObj.rolesInAAF = false;
110 component.applicationObj.isEnabled = false;
111 spyOn(component, 'saveChanges').and.callThrough();
112 component.saveChanges();
113 expect(component.saveChanges).toHaveBeenCalledWith();
114 component.applicationObj.isEnabled = true;
115 component.applicationObj.restrictedApp = true;
116 component.saveChanges();
117 expect(component.saveChanges).toHaveBeenCalledWith();
121 it('saveChanges URL validation changes', () => {
122 component.applicationObj.rolesInAAF = true;
123 component.applicationObj.isEnabled = true;
124 component.applicationObj.appName ='test';
125 component.applicationObj.landingPage = 'https://www.test.com'
126 component.applicationObj.appBasicAuthUsername ='test'
127 component.applicationObj.nameSpace ='ONAP'
128 spyOn(component, 'saveChanges').and.callThrough();
129 component.saveChanges();
130 expect(component.saveChanges).toHaveBeenCalledWith();
131 component.applicationObj.restrictedApp = false;
132 component.isEditMode = true;
133 component.saveChanges();
134 expect(component.saveChanges).toHaveBeenCalledWith();