From e212c74f27f4b540f67e60f8091e93e769ac9229 Mon Sep 17 00:00:00 2001 From: Indrijeet kumar Date: Thu, 5 Mar 2020 14:33:43 +0530 Subject: test cases written in header-tabs component test cases written in header-tabs component Issue-ID: PORTAL-813 Change-Id: I706335791380009df385c66f525f8a1b2faf5732 Signed-off-by: Indrijeet Kumar --- .../header-tabs.component.spec.ts | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'ecomp-sdk/epsdk-app-overlay') diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts index da392424..d8166076 100644 --- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts +++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/header-tabs-component/header-tabs.component.spec.ts @@ -4,10 +4,12 @@ import { HeaderTabsComponent } from './header-tabs.component'; import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; import { HttpClientTestingModule } from '@angular/common/http/testing'; import { RouterTestingModule } from '@angular/router/testing'; +import { CommonModule } from '@angular/common'; describe('MainComponentComponent', () => { let component: HeaderTabsComponent; let fixture: ComponentFixture; + beforeEach(async(() => { TestBed.configureTestingModule({ @@ -22,9 +24,51 @@ describe('MainComponentComponent', () => { fixture = TestBed.createComponent(HeaderTabsComponent); component = fixture.componentInstance; fixture.detectChanges(); + }); it('should create', () => { expect(component).toBeTruthy(); }); + + + it('should test if condition in ngOnInit method',()=>{ + component.reportId = "" + component.reportMode="" + component.ngOnInit(); + expect(component.finalReportId).toEqual("-1"); + expect(component.repMode).toEqual("Create"); + expect(component.reportId).toEqual("-1"); + expect(component.reportMode).toEqual("Create"); + }); + + it('should test else condition in ngOnInit method',()=>{ + component.reportId="Indrijeet"; + component.reportMode="kumar"; + component.ngOnInit(); + expect(component.finalReportId).toEqual(component.reportId); + }); + + it('should test if condition in ngAfterViewInit method',()=>{ + component.reportId = ""; + component.reportMode=""; + component.ngAfterViewInit(); + expect(component.finalReportId).toEqual("-1"); + expect(component.repMode).toEqual("Create"); + expect(component.reportId).toEqual("-1"); + expect(component.reportMode).toEqual("Create"); + }); + + it('should test else condition in ngAfterViewInit method',()=>{ + component.reportId="indrijeet"; + component.reportMode="kumar"; + component.ngAfterViewInit(); + expect(component.finalReportId).toEqual(component.reportId) + expect(component.repMode).toEqual(component.reportMode) + }); + + it('should test ngDoCheck method',()=>{ + component.ngDoCheck(); + console.log(component.tabChanged); + }) }); -- cgit 1.2.3-korg