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';
53 describe('ApplicationDetailsDialogComponent', () => {
54 let component: ApplicationDetailsDialogComponent;
55 let fixture: ComponentFixture<ApplicationDetailsDialogComponent>;
56 const applicationObj: IApplications = {"id":"testID"};
58 beforeEach(async(() => {
59 TestBed.configureTestingModule({
60 declarations: [ ApplicationDetailsDialogComponent,InformationModalComponent,ConfirmationModalComponent],
61 imports: [NgMaterialModule,FormsModule,HttpClientTestingModule,NgbModule.forRoot()],
62 providers: [NgbActiveModal]
63 }).overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent,ConfirmationModalComponent] } })
68 fixture = TestBed.createComponent(ApplicationDetailsDialogComponent);
69 component = fixture.componentInstance;
70 component.applicationObj = applicationObj;
71 fixture.detectChanges();
74 it('should create', () => {
75 expect(component).toBeTruthy();
77 it('removeImage should return stubbed value', () => {
78 spyOn(component, 'removeImage').and.callThrough();
79 component.removeImage();
80 expect(component.removeImage).toHaveBeenCalledWith();
82 it('saveChanges should return stubbed value', () => {
83 component.applicationObj.isCentralAuth = true;
84 component.applicationObj.isEnabled = false;
85 spyOn(component, 'saveChanges').and.callThrough();
86 component.saveChanges();
87 expect(component.saveChanges).toHaveBeenCalledWith();
88 component.applicationObj.isEnabled = true;
89 component.applicationObj.url = 'www.test.com'
90 component.applicationObj.restrictedApp =true;
92 //spyOn(component, 'saveChanges').and.callThrough();
93 component.saveChanges();
94 expect(component.saveChanges).toHaveBeenCalledWith();
95 component.applicationObj.isCentralAuth = false;
96 component.applicationObj.url = 'test'
97 component.applicationObj.restrictedApp =false;
98 component.applicationObj.isOpen = true;
99 component.isEditMode =true;
100 //spyOn(component, 'saveChanges').and.callThrough();
101 component.saveChanges();
102 expect(component.saveChanges).toHaveBeenCalledWith();
104 it('saveChanges Central Auth is disabled', () => {
105 component.applicationObj.isCentralAuth = false;
106 component.applicationObj.isEnabled = false;
107 spyOn(component, 'saveChanges').and.callThrough();
108 component.saveChanges();
109 expect(component.saveChanges).toHaveBeenCalledWith();
110 component.applicationObj.isEnabled = true;
111 component.applicationObj.restrictedApp = true;
112 component.saveChanges();
113 expect(component.saveChanges).toHaveBeenCalledWith();
117 it('saveChanges URL validation changes', () => {
118 component.applicationObj.isCentralAuth = true;
119 component.applicationObj.isEnabled = true;
120 component.applicationObj.name ='test';
121 component.applicationObj.url = 'https://www.test.com'
122 component.applicationObj.username ='test'
123 component.applicationObj.nameSpace ='ONAP'
124 spyOn(component, 'saveChanges').and.callThrough();
125 component.saveChanges();
126 expect(component.saveChanges).toHaveBeenCalledWith();
127 component.applicationObj.restrictedApp = false;
128 component.isEditMode = true;
129 component.saveChanges();
130 expect(component.saveChanges).toHaveBeenCalledWith();