summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIndrijeet kumar <indriku1@in.ibm.com>2020-03-06 15:17:43 +0530
committerIndrijeet kumar <indriku1@in.ibm.com>2020-03-06 15:17:52 +0530
commit3c39aa2da2b75950f4362d07ea5e617bb95fee31 (patch)
tree15bdf175e079e6701be0c7a1906e051d4da29a6d
parentc609ff2416224308262435b5d551700ef5f264d0 (diff)
some test cases in column-list component
some test cases in column-list component Issue-ID: PORTAL-813 Change-Id: Ib050c813f6ed2e7eb3708adb37183c2a2d47888c Signed-off-by: Indrijeet Kumar <indriku1@in.ibm.com>
-rw-r--r--ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.spec.ts129
1 files changed, 127 insertions, 2 deletions
diff --git a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.spec.ts b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.spec.ts
index 6d6e9431..8442c873 100644
--- a/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.spec.ts
+++ b/ecomp-sdk/epsdk-app-overlay/src/main/webapp/ngapp/src/app/pages/analytics/Report_List/Report/columns/column-list/column-list.component.spec.ts
@@ -1,4 +1,3 @@
-
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
import { MatPaginatorModule } from '@angular/material/paginator';
@@ -8,14 +7,20 @@ import { ColumnListComponent } from './column-list.component';
import { FormsModule } from '@angular/forms';
import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { HttpClientTestingModule } from '@angular/common/http/testing';
+import { ColumnService } from '../column.service';
+import 'rxjs/add/observable/of';
+import { Observable } from 'rxjs/Observable';
+
describe('ColumnListComponent', () => {
let component: ColumnListComponent;
let fixture: ComponentFixture<ColumnListComponent>;
+ let _columnService: ColumnService;
+
beforeEach(async(() => {
TestBed.configureTestingModule({
- declarations: [ ColumnListComponent ],
+ declarations: [ ColumnListComponent],
imports: [
NoopAnimationsModule,
MatPaginatorModule,
@@ -32,10 +37,130 @@ describe('ColumnListComponent', () => {
fixture = TestBed.createComponent(ColumnListComponent);
component = fixture.componentInstance;
fixture.detectChanges();
+ _columnService=TestBed.get(ColumnService);
});
it('should compile', () => {
expect(component).toBeTruthy();
});
+ it('should test editRecord method',()=>{
+ component.editRecord("id");
+ expect(component.showSpinner).toBe(true);
+ expect(component.columnId).toEqual("id");
+
+ })
+
+ it('should test subscribe in editRecord method',()=>{
+
+ let spy1=spyOn(_columnService,'getIndividualColumnData').and.returnValue(Observable.of('you object'));
+ let spy2=spyOn(_columnService,'getDrillDownReportList').and.returnValue(Observable.of('you object'));
+ let spy3=spyOn(_columnService,'getResponseTotalColsList').and.returnValue(Observable.of('you object'));
+ component.editRecord("id");
+
+ expect(component.columnId).toEqual("id");
+ expect(spy1).toHaveBeenCalled();
+ expect(spy2).toHaveBeenCalled();
+ expect(spy3).toHaveBeenCalled();
+
+ })
+
+ it('should test ngOnChanges method',()=>{
+ spyOn(console,'log');
+ component.ngOnChanges();
+ expect(console.log).toHaveBeenCalledWith("Hit");
+ })
+
+ it('should test close method',()=>{
+ let spy1=spyOn(_columnService,'getColumnList').and.returnValue(Observable.of(''));
+ component.close();
+ expect(spy1).toHaveBeenCalled();
+ expect(component.finalObjArr).toEqual([]);
+ expect(component.finalGetObj).toEqual('');
+ expect(component.dataSource.data).toEqual(component.finalObjArr);
+ expect(component.dataSource.sort).toEqual(component.sort);
+ expect(component.dataSource.paginator).toEqual(component.paginator);
+ expect(component.table.dataSource).toEqual(component.dataSource)
+ expect(component.showSpinner).toEqual(false);
+ })
+
+ it('should test complete method',()=>{
+ component.showEditDrillDownPage=true;
+ component.complete();
+ expect(component.showEditDrillDownPage).toBe(false);
+ expect(component.showConfirmButton).toBe(false);
+ })
+
+it('should test onCompleted method',()=>{
+ component.onCompleted("drilldownParamsArr");
+ expect(component.drilldownParams).toBeUndefined();
+})
+
+it('should test save method',()=>{
+ component.noWrap=true;
+ component.save();
+ expect(component.showSpinner).toBe(true);
+ expect(component.finalPOSTObj["tabId"]).toEqual("ColEdit");
+ expect(component.finalPOSTObj["tabName"]).toEqual("Column Edit");
+ expect(component.finalPOSTObj["colId"]).toEqual(component.id);
+ expect(component.finalPOSTObj["colName"]).toEqual(component.name);
+ expect(component.finalPOSTObj["colType"]).toEqual("");
+ expect(component.finalPOSTObj["colspan"]).toEqual(component.colspan);
+ expect(component.finalPOSTObj["dataType"]).toEqual(component.dataType);
+ expect(component.finalPOSTObj["depeondsOnForField"]).toEqual(component.dependsOnFormFields);
+ expect(component.finalPOSTObj["displayAlignment"]).toEqual(component.displayAlignment);
+ expect(component.finalPOSTObj["displayHeaderAlignment"]).toEqual(component.displayHeaderAlignment);
+ expect(component.finalPOSTObj["displayName"]).toEqual(component.displayName);
+ expect(component.finalPOSTObj["displayTotal"]).toEqual(component.displayTotal);
+ expect(component.finalPOSTObj["displayWidth"]).toEqual(10);
+ expect(component.finalPOSTObj["displayWidthInPixel"]).toEqual(component.displayWidthInPixel);
+ //expect(component.finalPOSTObj[""]).toEqual();
+ expect(component.finalPOSTObj["drilldownParams"]).toEqual(component.drilldownParams);
+ expect(component.finalPOSTObj["drilldownType"]).toEqual("");
+ expect(component.finalPOSTObj["drilldownURL"]).toEqual(component.drilldownURL);
+ expect(component.finalPOSTObj["errorMessage"]).toEqual("");
+ expect(component.finalPOSTObj["errorStackTrace"]).toEqual("");
+ expect(component.finalPOSTObj["groupByPos"]).toEqual(component.groupByPos);
+ expect(component.finalPOSTObj["hideRepeatedKey"]).toEqual(component.hideRepeatedValues);
+ expect(component.finalPOSTObj["indentation"]).toEqual(component.indentation);
+ expect(component.finalPOSTObj["level"]).toEqual(component.multiGroupColumnLevel);
+ expect(component.finalPOSTObj["noWrap"]).toEqual("Y");
+ expect(component.finalPOSTObj["sortable"]).toEqual(component.sortable);
+ expect(component.finalPOSTObj["subTotalCustomText"]).toEqual(component.displayTotal);
+ expect(component.finalPOSTObj["visible"]).toEqual(component.visible);
+
+
+})
+
+it('should test if codition inside save method',()=>{
+ component.showSaveColDialog=true;
+ let spy=spyOn(_columnService,'postColumnChanges').and.returnValue(Observable.of('you object'))
+ component.save();
+ expect(spy).toHaveBeenCalled();
+ expect(component.EditColstatus).toEqual("Success!");
+ expect(component.EditColmessage).toEqual("Your change has been saved! Row definition is updated.");
+ expect(component.showSaveColDialog).toBe(false);
+ expect(component.Colclosable).toBe(true);
+})
+
+it('should test else codition inside save method',()=>{
+ component.showSaveColDialog=true;
+ let spy=spyOn(_columnService,'postColumnChanges').and.returnValue(Observable.of(''))
+ component.save();
+ expect(spy).toHaveBeenCalled();
+ expect(component.EditColstatus).toEqual("Failure!");
+ expect(component.EditColmessage).toEqual("Row definition could not be updated.");
+ expect(component.showSaveColDialog).toBe(false);
+ expect(component.Colclosable).toBe(true);
+})
+
+it('should be testing drillDownLinkPage method',()=>{
+ component.showEditDrillDownPage=true
+ component.drillDownLinkPage();
+ expect(component.showEditDrillDownPage).toEqual(false);
+ expect(component.showConfirmButton).toBe(true);
+})
+
+
+
});