af8e9db77ec6c441a0ba75f51ee6043356daa2de
[portal/sdk.git] /
1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2
3 import { LogComponent } from './log.component';
4 import { HttpClientTestingModule } from '@angular/common/http/testing';
5 import { LogService } from './log.service';
6 import { MockBackend } from '@angular/http/testing';
7 import { BaseRequestOptions, Http } from '@angular/http';
8 import 'rxjs/add/observable/of';
9 import { Observable } from 'rxjs/Observable';
10
11 describe('LogComponent', () => {
12   let component: LogComponent;
13   let fixture: ComponentFixture<LogComponent>;
14   let logService:LogService;
15
16   beforeEach(async(() => {
17     TestBed.configureTestingModule({
18       declarations: [ LogComponent ],
19       imports: [HttpClientTestingModule]
20     })
21     .compileComponents();
22   }));
23
24   beforeEach(() => {
25     fixture = TestBed.createComponent(LogComponent);
26     component = fixture.componentInstance;
27     fixture.detectChanges();
28     logService=TestBed.get(LogService);
29   });
30
31   it('should create', () => {
32     expect(component).toBeTruthy();
33   });
34
35   describe('should test subscribe',()=>{
36     it('should test ngOnInit method1',()=>{
37       component.reportType = "Dashboard";
38       component.ngOnInit();
39       expect(component.stepNo).toEqual("3");
40     })
41   })
42
43   it('should test ngOnInit method2',()=>{
44     component.reportType != "Dashboard";
45     component.ngOnInit();
46     expect(component.stepNo).toEqual("7");
47   })
48
49   it('should test subscribe method inside ngOnInit method',()=>{
50     let spy=spyOn(logService,'getLogData').and.returnValue(Observable.of('you object'));
51     component.ngOnInit();
52     expect(spy).toHaveBeenCalled();
53   })
54 });