diff options
Diffstat (limited to 'ecomp-sdk/epsdk-app-overlay/src')
-rw-r--r-- | ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts index 250affed..e2b08a4f 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts @@ -1,14 +1,28 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing'; import { LogComponent } from './log.component'; +import { HttpClientTestingModule } from '@angular/common/http/testing'; +import { LogService } from './log.service'; +import { MockBackend } from '@angular/http/testing'; +import { BaseRequestOptions, Http } from '@angular/http'; +import 'rxjs/add/observable/of'; +import { Observable } from 'rxjs/Observable'; describe('LogComponent', () => { let component: LogComponent; let fixture: ComponentFixture<LogComponent>; + let logService:LogService; beforeEach(async(() => { TestBed.configureTestingModule({ - declarations: [ LogComponent ] + declarations: [ LogComponent ], + imports: [HttpClientTestingModule], + // providers:[LogService,MockBackend,BaseRequestOptions,{ + // porvide:Http,useFactory:(backend:MockBackend,defaultOptions:BaseRequestOptions)=>{ + // return new Http(backend,defaultOptions); + // }, + // deps:[MockBackend,BaseRequestOptions], + // }] }) .compileComponents(); })); @@ -17,9 +31,30 @@ describe('LogComponent', () => { fixture = TestBed.createComponent(LogComponent); component = fixture.componentInstance; fixture.detectChanges(); + logService=TestBed.get(LogService); }); it('should create', () => { expect(component).toBeTruthy(); }); + + describe('should test subscribe',()=>{ + it('should test ngOnInit method1',()=>{ + component.reportType = "Dashboard"; + component.ngOnInit(); + expect(component.stepNo).toEqual("3"); + }) + }) + + it('should test ngOnInit method2',()=>{ + component.reportType != "Dashboard"; + component.ngOnInit(); + expect(component.stepNo).toEqual("7"); + }) + + it('should test subscribe method inside ngOnInit method',()=>{ + let spy=spyOn(logService,'getLogData').and.returnValue(Observable.of('you object')); + component.ngOnInit(); + expect(spy).toHaveBeenCalled(); + }) }); |