d1ed806814a90bc3aafca1dab2de9f63fab5871c
[portal/sdk.git] /
1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 import { FormsModule } from '@angular/forms';
3 import { DashboardReportGridComponent } from './dashboard-report-grid.component';
4 import { CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
5 import { HttpClientTestingModule } from '@angular/common/http/testing';
6 import { DashboardReportService } from '../../run/run-report/run-dashboard-report/dashboard-report.service';
7 import { DashboardReportGridService } from './dashboard-report-grid.service';
8 import 'rxjs/add/observable/of';
9 import { Observable } from 'rxjs';
10 import { GridsterItem } from 'angular-gridster2';
11
12 describe('DashboardReportGridComponent', () => {
13   let component: DashboardReportGridComponent;
14   let fixture: ComponentFixture<DashboardReportGridComponent>;
15   let service;
16   let environment = [
17     {
18       baseUrl: 'just for testing'
19     }
20   ];
21
22   beforeEach(async(() => {
23     TestBed.configureTestingModule({
24       schemas: [CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA], 
25       declarations: [ DashboardReportGridComponent ],
26       imports: [FormsModule, HttpClientTestingModule]
27     })
28     .compileComponents();
29     service = TestBed.get(DashboardReportGridService);
30     spyOn(service, 'getReportList').and.returnValue(Observable.of(environment));
31   })); 
32
33   beforeEach(() => {
34     fixture = TestBed.createComponent(DashboardReportGridComponent);
35     component = fixture.componentInstance;
36     environment ["rows"] = [""];
37     component.dashboard ["hasContent"] = [""];
38     fixture.detectChanges();
39   });
40
41   it('should create', () => {
42     expect(component).toBeTruthy();
43   });
44
45   it('should test ngOnInit method', () => {
46     spyOn(component, 'ngOnInit').and.callThrough();
47       component.ngOnInit();
48       expect(component.ngOnInit).toHaveBeenCalled();
49   });
50
51   it('should test changedOption method', () => {    
52     component.changedOptions();
53   });
54
55   it('should test assignCopy method', () => {
56       component.assignCopy();
57   });
58
59   it('should test filterItem method', () => {
60       component.filterItem(1);
61   });
62
63   it('should test addItem method', () => {
64       component.addItem();
65   });
66
67   it('should test emptyCellClick method', () => {
68     let event: MouseEvent;
69     let item: GridsterItem;
70     component.emptyCellClick(event, item);
71   });
72
73 });