diff options
author | Lorraine Welch <lb2391@att.com> | 2020-04-01 16:34:16 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-04-01 16:34:16 +0000 |
commit | 8ef7821efbe7a7a0a4ae68a04928a89b0dcbac5f (patch) | |
tree | e42e12d86fdc3967fcb67ce2e860a61b8c92038a /ecomp-sdk/epsdk-app-overlay/src/main | |
parent | ffd302b5b1c325f4d905363d7c9beb49c826e9e2 (diff) | |
parent | 8fc2f12a1cc6a5e4dd346260624c4a9d54893587 (diff) |
Merge "test cases written in menus component"
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts | 54 |
1 files changed, 37 insertions, 17 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 5627abd0..eb8b63dd 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 @@ -2,6 +2,7 @@ import { async, ComponentFixture, TestBed, inject } from '@angular/core/testing' import { MatTableModule } from '@angular/material/table'; 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'; @@ -11,12 +12,19 @@ import { InformationModalComponent } from 'src/app/modals/information-modal/info import { AdminService } from '../admin.service'; 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'; describe('MenusComponent', () => { let component: MenusComponent; let fixture: ComponentFixture<MenusComponent>; let modalService: any; - let modalRef: any; + let adminService:any; + var stubData={"data":'{"fnMenuItems":{"tableData":{"element":{"active":1}}}}'}; beforeEach(async(() => { TestBed.configureTestingModule({ @@ -26,11 +34,14 @@ describe('MenusComponent', () => { imports: [ MatTableModule, MatPaginatorModule, MatSortModule, - HttpClientTestingModule, + HttpClientModule, + HttpClientTestingModule, NoopAnimationsModule, - NgbModule.forRoot() ] - }). - overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent] } });; + NgbModule.forRoot() + ], + providers:[MenusService,CookieService] + }) + .compileComponents(); })); beforeEach(async() => { @@ -38,24 +49,33 @@ describe('MenusComponent', () => { component = fixture.componentInstance; fixture.detectChanges(); modalService = TestBed.get(NgbModal); - modalRef = modalService.open(InformationModalComponent); - spyOn(modalService, "open").and.returnValue(modalRef); - spyOn(modalRef, "result").and.returnValue('Ok'); + adminService=TestBed.get(AdminService); }); it('should create', () => { expect(component).toBeTruthy(); }); - // it('should test getDismissReason function to call NgbModal.open function', () => { - // component.removeMenuItem({'label': 'abc'}); - // expect(modalService.open).toHaveBeenCalled(); - // }); + // 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')) + component.getParentData(); + expect(spy).toHaveBeenCalled(); + }) + }) -// it('should test getDismissReason function', inject([AdminService],(adminservice) => { -// let spy = spyOn(adminservice, 'getFnMenuItems'); -// component.getMenus(); -// expect(spy).toHaveBeenCalled(); -// })); + describe('testing getFunctionCDselectData',()=>{ + it('should test getFunctionCDselectData',()=>{ + let spy=spyOn(adminService,'getFunctionCdList').and.returnValue(Observable.of(1,1)); + component.getFunctionCDselectData(); + expect(spy).toHaveBeenCalled(); + }) + }) + }); |