summaryrefslogtreecommitdiffstats
path: root/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts
blob: e2b08a4f768c6311cc5c512cb0241be8e1b1fcab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { LogComponent } from './log.component';
import { HttpClientTestingModule } from '@angular/common/http/testing';
import { LogService } from './log.service';
import { MockBackend } from '@angular/http/testing';
import { BaseRequestOptions, Http } from '@angular/http';
import 'rxjs/add/observable/of';
import { Observable } from 'rxjs/Observable';

describe('LogComponent', () => {
  let component: LogComponent;
  let fixture: ComponentFixture<LogComponent>;
  let logService:LogService;

  beforeEach(async(() => {
    TestBed.configureTestingModule({
      declarations: [ LogComponent ],
      imports: [HttpClientTestingModule],
      // providers:[LogService,MockBackend,BaseRequestOptions,{
      //   porvide:Http,useFactory:(backend:MockBackend,defaultOptions:BaseRequestOptions)=>{
      //     return new Http(backend,defaultOptions);
      //   },
      //   deps:[MockBackend,BaseRequestOptions],
      // }]
    })
    .compileComponents();
  }));

  beforeEach(() => {
    fixture = TestBed.createComponent(LogComponent);
    component = fixture.componentInstance;
    fixture.detectChanges();
    logService=TestBed.get(LogService);
  });

  it('should create', () => {
    expect(component).toBeTruthy();
  });

  describe('should test subscribe',()=>{
    it('should test ngOnInit method1',()=>{
      component.reportType = "Dashboard";
      component.ngOnInit();
      expect(component.stepNo).toEqual("3");
    })
  })

  it('should test ngOnInit method2',()=>{
    component.reportType != "Dashboard";
    component.ngOnInit();
    expect(component.stepNo).toEqual("7");
  })

  it('should test subscribe method inside ngOnInit method',()=>{
    let spy=spyOn(logService,'getLogData').and.returnValue(Observable.of('you object'));
    component.ngOnInit();
    expect(spy).toHaveBeenCalled();
  })
});