1 import { async, ComponentFixture, TestBed } from '@angular/core/testing';
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';
11 describe('LogComponent', () => {
12 let component: LogComponent;
13 let fixture: ComponentFixture<LogComponent>;
14 let logService:LogService;
16 beforeEach(async(() => {
17 TestBed.configureTestingModule({
18 declarations: [ LogComponent ],
19 imports: [HttpClientTestingModule]
25 fixture = TestBed.createComponent(LogComponent);
26 component = fixture.componentInstance;
27 fixture.detectChanges();
28 logService=TestBed.get(LogService);
31 it('should create', () => {
32 expect(component).toBeTruthy();
35 describe('should test subscribe',()=>{
36 it('should test ngOnInit method1',()=>{
37 component.reportType = "Dashboard";
39 expect(component.stepNo).toEqual("3");
43 it('should test ngOnInit method2',()=>{
44 component.reportType != "Dashboard";
46 expect(component.stepNo).toEqual("7");
49 it('should test subscribe method inside ngOnInit method',()=>{
50 let spy=spyOn(logService,'getLogData').and.returnValue(Observable.of('you object'));
52 expect(spy).toHaveBeenCalled();