diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src/main/webapp')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/admin/usage/usage.component.spec.ts | 17 |
1 files changed, 16 insertions, 1 deletions
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<UsageComponent>; + 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(); + }) + }); |