From 20bf5cb610726771a9c540f0cbf9697e327994f7 Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Tue, 14 Apr 2020 00:46:29 +0530 Subject: test cases in menus component test cases in menus component Issue-ID: PORTAL-813 Change-Id: I4703e1b617e7959b0817583102c76df89fe0ebe1 Signed-off-by: Indrijeet Kumar --- .../app/pages/admin/menus/menus.component.spec.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 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; 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(); +}) + }); -- cgit 1.2.3-korg