fa856c009087a58cff003900e928a8b53e134a64
[portal/sdk.git] /
1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 import { NoopAnimationsModule } from '@angular/platform-browser/animations';
3 import { MatPaginatorModule } from '@angular/material/paginator';
4 import { MatSortModule } from '@angular/material/sort';
5 import { MatTableModule } from '@angular/material/table';
6
7 import { RunReportResultSetComponent } from './run-report-result-set.component';
8 import { HttpClientTestingModule } from '@angular/common/http/testing';
9 import { RouterTestingModule } from '@angular/router/testing';
10 import { RunService } from '../run.service';
11 import 'rxjs/add/observable/of';
12 import { Observable } from 'rxjs/Observable';
13 import 'rxjs/add/operator/catch';
14 import 'rxjs/add/observable/throw';
15
16 describe('RunReportResultSetComponent', () => {
17   let component: RunReportResultSetComponent;
18   let fixture: ComponentFixture<RunReportResultSetComponent>;
19   let _runService:RunService;
20   var response={
21                  "reportDataColumns":[{"columnTitle":"columnTitle"}],
22                  "reportDataRows":[{"colId":"colId"}]
23                 }
24
25   beforeEach(async(() => {
26     TestBed.configureTestingModule({
27       declarations: [ RunReportResultSetComponent ],
28       imports: [
29         NoopAnimationsModule,
30         MatPaginatorModule,
31         MatSortModule,
32         MatTableModule,
33         HttpClientTestingModule,
34         RouterTestingModule
35       ],
36     }).compileComponents();
37   }));
38
39   beforeEach(() => {
40     fixture = TestBed.createComponent(RunReportResultSetComponent);
41     component = fixture.componentInstance;
42     fixture.detectChanges();
43     _runService=TestBed.get(RunService);
44   });
45
46   it('should compile', () => {
47     expect(component).toBeTruthy();
48   });
49
50   it('should test ngOnInit method',()=>{
51     component.reportId1="reportId1";
52     let spy=spyOn(_runService,'getReportData').and.returnValue(Observable.of(response));
53     component.ngOnInit();
54     expect(spy).toHaveBeenCalled();
55
56   })
57
58   it('should test ngAfterViewInit method',()=>{
59     component.reportId1="reportId1";
60     let spy=spyOn(_runService,'getReportData').and.returnValue(Observable.of(response))
61     component.ngAfterViewInit();
62     expect(spy).toHaveBeenCalled();
63   })
64
65 });