test cases for log component 14/103014/1
authorIndrijeet kumar <indriku1@in.ibm.com>
Wed, 4 Mar 2020 14:59:56 +0000 (20:29 +0530)
committerIndrijeet kumar <indriku1@in.ibm.com>
Wed, 4 Mar 2020 15:00:05 +0000 (20:30 +0530)
test cases for log component

Issue-ID: PORTAL-813
Change-Id: Ieb84567bb45524d9edf677d6e00828b07970d580
Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/log/log.component.spec.ts

index 250affe..e2b08a4 100644 (file)
@@ -1,14 +1,28 @@
 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 ]
+      declarations: [ LogComponent ],
+      imports: [HttpClientTestingModule],
+      // providers:[LogService,MockBackend,BaseRequestOptions,{
+      //   porvide:Http,useFactory:(backend:MockBackend,defaultOptions:BaseRequestOptions)=>{
+      //     return new Http(backend,defaultOptions);
+      //   },
+      //   deps:[MockBackend,BaseRequestOptions],
+      // }]
     })
     .compileComponents();
   }));
@@ -17,9 +31,30 @@ describe('LogComponent', () => {
     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();
+  })
 });