diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src')
7 files changed, 204 insertions, 35 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts index eb8b63dd..08e57de2 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts @@ -4,9 +4,7 @@ import { MatPaginatorModule } from '@angular/material/paginator'; import { MatSortModule } from '@angular/material/sort'; import { HttpClientModule } from '@angular/common/http'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; -import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; import { NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap'; - import { MenusComponent } from './menus.component'; import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; import { AdminService } from '../admin.service'; @@ -14,17 +12,19 @@ import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { MenusService } from './menus.service'; import { CookieService } from 'ngx-cookie-service'; -import { MockBackend } from '@angular/http/testing'; -import { BaseRequestOptions, Http } from '@angular/http'; import 'rxjs/add/observable/of'; import { Observable } from 'rxjs/Observable'; +import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/throw'; describe('MenusComponent', () => { let component: MenusComponent; let fixture: ComponentFixture<MenusComponent>; let modalService: any; let adminService:any; - var stubData={"data":'{"fnMenuItems":{"tableData":{"element":{"active":1}}}}'}; + var stubData={ + "data1":{"data":"cachedRegions"} + } beforeEach(async(() => { TestBed.configureTestingModule({ @@ -56,11 +56,6 @@ describe('MenusComponent', () => { expect(component).toBeTruthy(); }); - // it('should test getFnMenuItems method inside getMenus',()=>{ - // let spy=spyOn(adminService,'getFnMenuItems').and.returnValue(Observable.of(stubData)) - // component.getMenus(); - // expect(spy).toHaveBeenCalled(); - // }) describe('test getMenus',()=>{ it('should test getMenus',()=>{ let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.of('you object')) @@ -76,6 +71,11 @@ describe('MenusComponent', () => { expect(spy).toHaveBeenCalled(); }) }) - + it('should test getParentData method error part ',()=>{ + let spy=spyOn(adminService,'getParentData').and.returnValue(Observable.throw({status:404})); + component.getParentData(); + expect(spy).toHaveBeenCalled(); +}) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts index c39dcdc0..8d5c6637 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.service.spec.ts @@ -53,7 +53,7 @@ describe('MenusService', () => { let component:MenusService; let service:AdminService; - var stubData={"data":{"active":"data2"}} + var stubData={"data":['{"active":"data"}','{"separator":"data1"}']}; beforeEach(() =>{ TestBed.configureTestingModule({ @@ -69,6 +69,24 @@ describe('MenusService', () => { expect(component).toBeTruthy(); }); + // it('should test getTotalRowCount method',()=>{ + // component.getTotalRowCount(); + // }) + + it('should test updateStatus method',()=>{ + component['updateStatus']('N'); + }) + + it('should test updateBooleanValue method',()=>{ + component['updateBooleanValue'](true); + component['updateBooleanValue'](false); + }) + + it('should test updateParentNameToID method',()=>{ + component.parentList=[{'name':'data'}]; + component['updateParentNameToID']('data'); + }) + it('should test menu',()=>{ console.log(component.menu); expect(component.menu.action).toEqual(null); @@ -90,4 +108,27 @@ describe('MenusService', () => { expect(spy).toHaveBeenCalled(); }) + + it('should test delete method',()=>{ + let spy=spyOn(service,'deleteMenu').and.returnValue(Observable.of("")); + component.delete(stubData); + expect(spy).toHaveBeenCalled(); + }) + + it('should test error part of delete method',()=>{ + let spy=spyOn(service,'deleteMenu').and.returnValue(Observable.throw({status:404})); + component.delete(stubData); + expect(spy).toHaveBeenCalled(); + }) + + it('should test getParentList method',()=>{ + component.getParentList("getParentList"); + expect(component.parentList).toEqual("getParentList"); + }) + + it('should test get method',()=>{ + let spy=spyOn(service,'getFnMenuItems').and.returnValue(Observable.of()); + component.get(); + expect(spy).toHaveBeenCalled(); + }) }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts index 7dc3aa9f..0e59f9eb 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/role-functions/role-functions.service.spec.ts @@ -13,7 +13,8 @@ describe('RoleFunctionsService', () => { let component:RoleFunctionsService; let service:AdminService; - var stubData={"data":{"active":"data2"}} + //var stubData=['{"data":'{"active":"data2"}'}'] + //var stubData1='{stubData}' beforeEach(() =>{ TestBed.configureTestingModule({ @@ -39,6 +40,12 @@ describe('RoleFunctionsService', () => { expect(spy).toHaveBeenCalled(); }) + it('should test error part of update method',()=>{ + let spy=spyOn(service,'saveRoleFunction').and.returnValue(Observable.throw({status:404})); + component.update("data"); + expect(spy).toHaveBeenCalled(); +}) + it('should test delete method',()=>{ let spy=spyOn(service,'deleteRoleFunction').and.returnValue(Observable.of('your object')); @@ -46,5 +53,10 @@ describe('RoleFunctionsService', () => { expect(spy).toHaveBeenCalled(); }) + it('should test get method',()=>{ + let spy=spyOn(service,'getRoleFunctionList').and.returnValue(Observable.of()) + component.get(); + expect(spy).toHaveBeenCalled(); + }) });
\ No newline at end of file diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts index dcd637fc..92d96135 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/roles/roles.component.spec.ts @@ -47,9 +47,10 @@ import { MatTableModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { UserService } from 'src/app/shared/services/user/user.service'; import { Observable } from 'rxjs'; -import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; +import { NgbModule, ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; +import { NewRoleComponent } from './new-role/new-role.component'; describe('RolesComponent', () => { let component: RolesComponent; @@ -102,4 +103,20 @@ describe('RolesComponent', () => { // it('should test openAdoleModaldNewR method',()=>{ // component.openAdoleModaldNewR('dummydata2') // }) + + it('should test openAdoleModaldNewR method',()=>{ + component.toggleRole("") + }) + + it('should test getDismissReason method',()=>{ + component['getDismissReason'](ModalDismissReasons.ESC); + component['getDismissReason'](ModalDismissReasons.BACKDROP_CLICK); + component['getDismissReason'](""); + }) + + // it('should test applyFilter method',()=>{ + // component.applyFilter("filterValue T"); + // expect(component.dataSource.filter).toEqual("filtervalue"); + // }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts index 2140e0ae..ab0efdb2 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/search/search.component.spec.ts @@ -1,4 +1,3 @@ - /* * ============LICENSE_START========================================== * ONAP Portal SDK @@ -17,16 +16,33 @@ * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and * limitations under the License. * * ============LICENSE_END============================================ * * */ + import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + import { SearchComponent } from './search.component'; -import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule } from '@angular/core'; -import { MatTableModule, MatTableDataSource, MatMenuModule, MatSortModule, MatPaginatorModule } from '@angular/material'; +import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA, NgModule, Component } from '@angular/core'; +import { MatTableModule, MatTableDataSource, MatMenuModule, MatSortModule, MatPaginatorModule, MatDialogModule } from '@angular/material'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { NoopAnimationsModule } from '@angular/platform-browser/animations'; import { RouterTestingModule } from '@angular/router/testing'; @@ -35,13 +51,23 @@ import { NgbModule, NgbModal } from '@ng-bootstrap/ng-bootstrap'; import { BrowserDynamicTestingModule } from '@angular/platform-browser-dynamic/testing'; import { NgbModalBackdrop } from '@ng-bootstrap/ng-bootstrap/modal/modal-backdrop'; import { NgModel } from '@angular/forms'; +import { Observable } from 'rxjs'; +import 'rxjs/add/observable/empty'; +import 'rxjs/add/observable/of'; +import { environment } from 'src/environments/environment'; +import { User } from 'src/app/shared/services/user/user'; +import { DataSource } from '@angular/cdk/table'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; + describe('SearchComponent', () => { let component: SearchComponent; let fixture: ComponentFixture<SearchComponent>; + let resp : any; + beforeEach(async(() => { TestBed.configureTestingModule({ schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], - declarations: [ SearchComponent , ConfirmationModalComponent], + declarations: [ SearchComponent , ConfirmationModalComponent, InformationModalComponent], imports: [NoopAnimationsModule, MatPaginatorModule, MatSortModule, @@ -49,35 +75,39 @@ describe('SearchComponent', () => { MatMenuModule, HttpClientTestingModule, RouterTestingModule, + MatDialogModule, + NgbModule.forRoot() ] }) + TestBed.overrideModule(BrowserDynamicTestingModule,{ + set:{ + entryComponents:[ConfirmationModalComponent,InformationModalComponent] + } + }) .compileComponents(); })); + beforeEach(() => { fixture = TestBed.createComponent(SearchComponent); component = fixture.componentInstance; + component.response = resp; fixture.detectChanges(); }); + it('should create', () => { expect(component).toBeTruthy(); }); + it('should test getUsers method', () => { component.getUsers(); - expect(component.showSpinner).toEqual(true); - let response; - component.response.subscribe(data => { - expect(response).toEqual(data); - expect(component.result).toEqual(JSON.parse(response.data)); - expect(component.profileList).toEqual(JSON.parse(component.result.profileList)); - expect(component.dataSource).toEqual(new MatTableDataSource(component.profileList)); - expect(component.dataSource.paginator).toEqual(component.paginator); - expect(component.dataSource.sort).toEqual(component.sort); - expect(component.showSpinner).toEqual(false); - }); }); - // it('should test applyFilter method', () => { - // let filterValue = "test" - // component.applyFilter(filterValue); - // expect(component.dataSource.filter).toEqual(filterValue.trim().toLowerCase()); - // }); -});
\ No newline at end of file + + it('should test openConfirmationModal method', () => { + component.openConfirmationModal("just","test"); + }); + + it('should test openInformationModal method', () => { + component.openInformationModal("just","test"); + }); + +}); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts index 97e164df..ee8f7b64 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/ext/profile/self/self.component.spec.ts @@ -50,6 +50,7 @@ import { UserService } from 'src/app/shared/services/user/user.service'; import { Observable } from 'rxjs'; import { ActivatedRoute } from '@angular/router'; import { RouterTestingModule } from '@angular/router/testing'; +import { ModalDismissReasons } from '@ng-bootstrap/ng-bootstrap'; describe('SelfComponent', () => { let component: SelfComponent; @@ -94,4 +95,10 @@ describe('SelfComponent', () => { }) }) + it('should test getDismissReason method',()=>{ + component['getDismissReason'](ModalDismissReasons.ESC); + component['getDismissReason'](ModalDismissReasons.BACKDROP_CLICK); + component['getDismissReason'](""); + }) + }); diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.spec.ts new file mode 100644 index 00000000..e82a7ebc --- /dev/null +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/shared/interceptors/header-interceptor.spec.ts @@ -0,0 +1,62 @@ +/*- + * ============LICENSE_START========================================== + * ONAP Portal SDK + * =================================================================== + * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * =================================================================== + * Modification Copyright © 2020 IBM. + * =================================================================== + * + * Unless otherwise specified, all software contained herein is licensed + * under the Apache License, Version 2.0 (the "License"); + * you may not use this software except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Unless otherwise specified, all documentation contained herein is licensed + * under the Creative Commons License, Attribution 4.0 Intl. (the "License"); + * you may not use this documentation except in compliance with the License. + * You may obtain a copy of the License at + * + * https://creativecommons.org/licenses/by/4.0/ + * + * Unless required by applicable law or agreed to in writing, documentation + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * ============LICENSE_END============================================ + * + * + */ + +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +import { HeaderInterceptor } from './header-interceptor'; + +describe('HeaderInterceptor', () => { + let component: HeaderInterceptor; + let fixture: ComponentFixture<HeaderInterceptor>; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + }) + .compileComponents(); + })); + + beforeEach(() => { + component=new HeaderInterceptor() + }); + + it('should create', () => { + expect(component).toBeTruthy(); + component.intercept; + }); +}); |