From c1770f10e548b96faf6d34c6a9b9b54c535fd101 Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Tue, 14 Apr 2020 00:29:35 +0530 Subject: test cases written in usage component test cases written in usage component Issue-ID: PORTAL-813 Change-Id: I892e96ba686f569c2c6db9a75131daa45af4967e Signed-off-by: Indrijeet Kumar --- .../src/app/pages/admin/usage/usage.component.spec.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'ecomp-sdk/epsdk-app-overlay/src') diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/usage/usage.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/usage/usage.component.spec.ts index 01f31669..f283855d 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/usage/usage.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/usage/usage.component.spec.ts @@ -44,16 +44,23 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { UsageComponent } from './usage.component'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { AdminComponent } from '../admin.component'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; describe('UsageComponent', () => { let component: UsageComponent; let fixture: ComponentFixture; + let adminService:AdminComponent; + var stubData={ + "data":'[{"data":"cachedRegions"}]'} beforeEach(async(() => { TestBed.configureTestingModule({ declarations: [ UsageComponent ], schemas:[CUSTOM_ELEMENTS_SCHEMA], - imports:[HttpClientTestingModule] + imports:[HttpClientTestingModule], + providers:[AdminComponent] }) .compileComponents(); })); @@ -62,9 +69,17 @@ describe('UsageComponent', () => { fixture = TestBed.createComponent(UsageComponent); component = fixture.componentInstance; fixture.detectChanges(); + adminService=TestBed.get(AdminComponent); }); it('should create', () => { expect(component).toBeTruthy(); }); + + it('should test ngOnInit method',()=>{ + let spy=spyOn(component.adminService,'getUsageList').and.returnValue(Observable.of(stubData)); + component.ngOnInit(); + expect(spy).toHaveBeenCalled(); + }) + }); -- cgit 1.2.3-korg