diff options
author | Arundathi Patil <arundpil@in.ibm.com> | 2019-12-04 15:51:42 +0530 |
---|---|---|
committer | Arundathi Patil <arundpil@in.ibm.com> | 2019-12-04 15:51:56 +0530 |
commit | 9c1e2002a5dd5c4bdbd8db0d2b9d29da7516f096 (patch) | |
tree | a87892bec59644cf03c33d65c8d1cd5968f8cf12 /ecomp-sdk | |
parent | beabe647ed84f9a5fea3e9633267e713e19f3750 (diff) |
menu component- test cases
wrote test case for menu component
Issue-ID: PORTAL-416
Change-Id: I5884c703a81d101a266742b529e95dbdbe808f17
Signed-off-by: Arundathi Patil <arundpil@in.ibm.com>
Diffstat (limited to 'ecomp-sdk')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/menus/menus.component.spec.ts | 37 |
1 files changed, 32 insertions, 5 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 9984ceee..04a691b9 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 @@ -1,25 +1,52 @@ -import { async, ComponentFixture, TestBed } from '@angular/core/testing'; +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'; import { MenusComponent } from './menus.component'; +import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component'; +import { AdminService } from '../admin.service'; describe('MenusComponent', () => { let component: MenusComponent; let fixture: ComponentFixture<MenusComponent>; + let modalService: any; + let modalRef: any; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ MenusComponent ] - }) - .compileComponents(); + declarations: [ MenusComponent, InformationModalComponent ], + imports: [ MatTableModule, MatPaginatorModule, MatSortModule, HttpClientModule, NoopAnimationsModule, NgbModule.forRoot() ] + }). + overrideModule(BrowserDynamicTestingModule, { set: { entryComponents: [InformationModalComponent] } });; })); - beforeEach(() => { + beforeEach(async() => { fixture = TestBed.createComponent(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'); }); 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 getDismissReason function', inject([AdminService],(adminservice) => { + component.getMenus(); + expect(adminservice.getFnMenuItems).toHaveBeenCalled(); + })); + }); |