diff options
author | 2020-04-01 21:43:35 +0530 | |
---|---|---|
committer | 2020-04-01 21:43:42 +0530 | |
commit | 8fc2f12a1cc6a5e4dd346260624c4a9d54893587 (patch) | |
tree | 1cb672866746239462b03802443946c82191c10a | |
parent | 7d3ad2425c0a774179ddb522e741d977c3bcf992 (diff) |
test cases written in menus component
test cases written in menus component
Issue-ID: PORTAL-813
Change-Id: I7dba050b758bad3939ece69b4eda22b14121767e
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
-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(); + }) + }) + }); |