import { RunReportResultSetComponent } from './run-report-result-set.component';
import { HttpClientTestingModule } from '@angular/common/http/testing';
-import { HttpClient } from '@angular/common/http';
import { RouterTestingModule } from '@angular/router/testing';
+import { RunService } from '../run.service';
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs/Observable';
+import 'rxjs/add/operator/catch';
+import 'rxjs/add/observable/throw';
describe('RunReportResultSetComponent', () => {
let component: RunReportResultSetComponent;
let fixture: ComponentFixture<RunReportResultSetComponent>;
+ let _runService:RunService;
+ var response={
+ "reportDataColumns":[{"columnTitle":"columnTitle"}],
+ "reportDataRows":[{"colId":"colId"}]
+ }
beforeEach(async(() => {
TestBed.configureTestingModule({
fixture = TestBed.createComponent(RunReportResultSetComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ _runService=TestBed.get(RunService);
});
it('should compile', () => {
expect(component).toBeTruthy();
});
+
+ it('should test ngOnInit method',()=>{
+ component.reportId1="reportId1";
+ let spy=spyOn(_runService,'getReportData').and.returnValue(Observable.of(response));
+ component.ngOnInit();
+ expect(spy).toHaveBeenCalled();
+
+ })
+
+ it('should test ngAfterViewInit method',()=>{
+ component.reportId1="reportId1";
+ let spy=spyOn(_runService,'getReportData').and.returnValue(Observable.of(response))
+ component.ngAfterViewInit();
+ expect(spy).toHaveBeenCalled();
+ })
+
});