Skip to content

Commit a798252

Browse files
committed
Adding tests for issue 174
1 parent 517ce9d commit a798252

File tree

2 files changed

+160
-6
lines changed

2 files changed

+160
-6
lines changed

src/igniteui.angular2.ts

Lines changed: 64 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,6 +1041,63 @@ export class IgGridTooltipsFeature extends Feature<IgGridTooltips> {
10411041
public id(): string { return; } ;
10421042
}
10431043

1044+
@Directive({
1045+
selector: 'append-rows-on-demand',
1046+
inputs: ["type","chunkSize","recordCountKey","chunkSizeUrlKey","chunkIndexUrlKey","defaultChunkIndex","currentChunkIndex","loadTrigger","loadMoreDataButtonText"],
1047+
outputs: ["rowsRequesting","rowsRequested"]
1048+
})
1049+
export class IgGridAppendRowsOnDemandFeature extends Feature<IgGridAppendRowsOnDemand> {
1050+
constructor(el: ElementRef) {
1051+
super(el);
1052+
}
1053+
1054+
/**
1055+
* Destroys the append rows on demand widget
1056+
*/
1057+
public destroy(): void { return; } ;
1058+
1059+
/**
1060+
* Loads the next chunk of data.
1061+
*/
1062+
public nextChunk(): void { return; } ;
1063+
}
1064+
1065+
@Directive({
1066+
selector: 'multi-column-headers',
1067+
inputs: ["inherit"],
1068+
outputs: ["groupCollapsing","groupCollapsed","groupExpanding","groupExpanded"]
1069+
})
1070+
export class IgGridMultiColumnHeadersFeature extends Feature<IgGridMultiColumnHeaders> {
1071+
constructor(el: ElementRef) {
1072+
super(el);
1073+
}
1074+
1075+
/**
1076+
* Destroys the widget
1077+
*/
1078+
public destroy(): void { return; } ;
1079+
1080+
/**
1081+
* Collapses an expanded group. If the group is collapsed, the method does nothing.
1082+
* Note: This method is asynchronous which means that it returns immediately and any subsequent code will execute in parallel. This may lead to runtime errors. To avoid them put the subsequent code in the callback parameter provided by the method.
1083+
*/
1084+
public collapseGroup(groupKey: string, callback?: Function): void { return; } ;
1085+
/**
1086+
* Expands a collapsed group. If the group is expanded, the method does nothing.
1087+
* Note: This method is asynchronous which means that it returns immediately and any subsequent code will execute in parallel. This may lead to runtime errors. To avoid them put the subsequent code in the callback parameter provided by the method.
1088+
*/
1089+
public expandGroup(groupKey: string, callback?: Function): void { return; } ;
1090+
/**
1091+
* Returns multicolumn headers array. if there aren"t multicolumn headers returns undefined.
1092+
*/
1093+
public getMultiColumnHeaders(): Array<Column> { return; } ;
1094+
/**
1095+
* Toggles a collapsible group.
1096+
* Note: This method is asynchronous which means that it returns immediately and any subsequent code will execute in parallel. This may lead to runtime errors. To avoid them put the subsequent code in the callback parameter provided by the method.
1097+
*/
1098+
public toggleGroup(groupKey: string, callback?: Function): void { return; } ;
1099+
}
1100+
10441101
@Directive({
10451102
selector: 'features'
10461103
})
@@ -1061,6 +1118,8 @@ export class Features implements AfterContentInit {
10611118
@ContentChild(IgGridSummariesFeature) summaries: IgGridSummariesFeature;
10621119
@ContentChild(IgGridColumnFixingFeature) columnFixing: IgGridColumnFixingFeature;
10631120
@ContentChild(IgGridTooltipsFeature) tooltips: IgGridTooltipsFeature;
1121+
@ContentChild(IgGridAppendRowsOnDemandFeature) appendRowsOnDemand: IgGridAppendRowsOnDemand;
1122+
@ContentChild(IgGridMultiColumnHeadersFeature) multiColumnHeaders: IgGridMultiColumnHeaders;
10641123

10651124
ngAfterContentInit() {
10661125
this.filtering ? this.allFeatures.push(this.filtering): null;
@@ -1071,16 +1130,16 @@ export class Features implements AfterContentInit {
10711130
this.moving ? this.allFeatures.push(this.moving): null;
10721131
this.hiding ? this.allFeatures.push(this.hiding): null;
10731132
this.responsive ? this.allFeatures.push(this.responsive): null;
1074-
this.responsive ? this.allFeatures.push(this.responsive): null;
1133+
this.cellMerging ? this.allFeatures.push(this.cellMerging): null;
10751134
this.resizing ? this.allFeatures.push(this.resizing): null;
10761135
this.selection ? this.allFeatures.push(this.selection): null;
10771136
this.rowSelectors ? this.allFeatures.push(this.rowSelectors): null;
10781137
this.summaries ? this.allFeatures.push(this.summaries): null;
10791138
this.columnFixing ? this.allFeatures.push(this.columnFixing): null;
10801139
this.tooltips ? this.allFeatures.push(this.tooltips): null;
1140+
this.appendRowsOnDemand ? this.allFeatures.push(this.appendRowsOnDemand): null;
1141+
this.multiColumnHeaders ? this.allFeatures.push(this.multiColumnHeaders): null;
10811142
}
1082-
1083-
10841143
}
10851144

10861145
export class IgControlBase<Model> implements DoCheck {
@@ -5691,7 +5750,7 @@ export class IgSpreadsheetComponent extends IgControlBase<IgSpreadsheet> {
56915750
}
56925751

56935752
@NgModule({
5694-
declarations: [Column,IgGridSortingFeature,IgGridFilteringFeature,IgGridPagingFeature,IgGridUpdatingFeature,IgGridGroupByFeature,IgGridColumnMovingFeature,IgGridHidingFeature,IgGridCellMergingFeature,IgGridResponsiveFeature,IgGridResizingFeature,IgGridSelectionFeature,IgGridRowSelectorsFeature,IgGridSummariesFeature,IgGridColumnFixingFeature,IgGridTooltipsFeature,Features,IgGridComponent,IgTreeGridComponent,IgHierarchicalGridComponent,IgComboComponent,IgCheckboxEditorComponent,IgCurrencyEditorComponent,IgDateEditorComponent,IgDatePickerComponent,IgMaskEditorComponent,IgNumericEditorComponent,IgPercentEditorComponent,IgTextEditorComponent,IgTreeComponent,IgDialogComponent,IgSplitterComponent,IgLayoutManagerComponent,IgTileManagerComponent,IgHtmlEditorComponent,IgValidatorComponent,IgPivotDataSelectorComponent,IgPivotGridComponent,IgDataChartComponent,IgPieChartComponent,IgDoughnutChartComponent,IgFunnelChartComponent,IgRadialGaugeComponent,IgZoombarComponent,IgMapComponent,IgSparklineComponent,IgBulletGraphComponent,IgLinearGaugeComponent,IgQRCodeBarcodeComponent,IgUploadComponent,IgPopoverComponent,IgNotifierComponent,IgRatingComponent,IgVideoPlayerComponent,IgRadialMenuComponent,IgSplitButtonComponent, IgSpreadsheetComponent, IgSchedulerComponent],
5695-
exports: [Column,IgGridSortingFeature,IgGridFilteringFeature,IgGridPagingFeature,IgGridUpdatingFeature,IgGridGroupByFeature,IgGridColumnMovingFeature,IgGridHidingFeature,IgGridCellMergingFeature,IgGridResponsiveFeature,IgGridResizingFeature,IgGridSelectionFeature,IgGridRowSelectorsFeature,IgGridSummariesFeature,IgGridColumnFixingFeature,IgGridTooltipsFeature,Features,IgGridComponent,IgTreeGridComponent,IgHierarchicalGridComponent,IgComboComponent,IgCheckboxEditorComponent,IgCurrencyEditorComponent,IgDateEditorComponent,IgDatePickerComponent,IgMaskEditorComponent,IgNumericEditorComponent,IgPercentEditorComponent,IgTextEditorComponent,IgTreeComponent,IgDialogComponent,IgSplitterComponent,IgLayoutManagerComponent,IgTileManagerComponent,IgHtmlEditorComponent,IgValidatorComponent,IgPivotDataSelectorComponent,IgPivotGridComponent,IgDataChartComponent,IgPieChartComponent,IgDoughnutChartComponent,IgFunnelChartComponent,IgRadialGaugeComponent,IgZoombarComponent,IgMapComponent,IgSparklineComponent,IgBulletGraphComponent,IgLinearGaugeComponent,IgQRCodeBarcodeComponent,IgUploadComponent,IgPopoverComponent,IgNotifierComponent,IgRatingComponent,IgVideoPlayerComponent,IgRadialMenuComponent,IgSplitButtonComponent, IgSpreadsheetComponent, IgSchedulerComponent]
5753+
declarations: [Column,IgGridSortingFeature,IgGridFilteringFeature,IgGridPagingFeature,IgGridUpdatingFeature,IgGridGroupByFeature,IgGridColumnMovingFeature,IgGridHidingFeature,IgGridCellMergingFeature,IgGridResponsiveFeature,IgGridResizingFeature,IgGridSelectionFeature,IgGridRowSelectorsFeature,IgGridSummariesFeature,IgGridColumnFixingFeature,IgGridTooltipsFeature,IgGridAppendRowsOnDemandFeature,Features,IgGridComponent,IgTreeGridComponent,IgHierarchicalGridComponent,IgComboComponent,IgCheckboxEditorComponent,IgCurrencyEditorComponent,IgDateEditorComponent,IgDatePickerComponent,IgMaskEditorComponent,IgNumericEditorComponent,IgPercentEditorComponent,IgTextEditorComponent,IgTreeComponent,IgDialogComponent,IgSplitterComponent,IgLayoutManagerComponent,IgTileManagerComponent,IgHtmlEditorComponent,IgValidatorComponent,IgPivotDataSelectorComponent,IgPivotGridComponent,IgDataChartComponent,IgPieChartComponent,IgDoughnutChartComponent,IgFunnelChartComponent,IgRadialGaugeComponent,IgZoombarComponent,IgMapComponent,IgSparklineComponent,IgBulletGraphComponent,IgLinearGaugeComponent,IgQRCodeBarcodeComponent,IgUploadComponent,IgPopoverComponent,IgNotifierComponent,IgRatingComponent,IgVideoPlayerComponent,IgRadialMenuComponent,IgSplitButtonComponent, IgSpreadsheetComponent, IgSchedulerComponent],
5754+
exports: [Column,IgGridSortingFeature,IgGridFilteringFeature,IgGridPagingFeature,IgGridUpdatingFeature,IgGridGroupByFeature,IgGridColumnMovingFeature,IgGridHidingFeature,IgGridCellMergingFeature,IgGridResponsiveFeature,IgGridResizingFeature,IgGridSelectionFeature,IgGridRowSelectorsFeature,IgGridSummariesFeature,IgGridColumnFixingFeature,IgGridTooltipsFeature,IgGridAppendRowsOnDemandFeature,Features,IgGridComponent,IgTreeGridComponent,IgHierarchicalGridComponent,IgComboComponent,IgCheckboxEditorComponent,IgCurrencyEditorComponent,IgDateEditorComponent,IgDatePickerComponent,IgMaskEditorComponent,IgNumericEditorComponent,IgPercentEditorComponent,IgTextEditorComponent,IgTreeComponent,IgDialogComponent,IgSplitterComponent,IgLayoutManagerComponent,IgTileManagerComponent,IgHtmlEditorComponent,IgValidatorComponent,IgPivotDataSelectorComponent,IgPivotGridComponent,IgDataChartComponent,IgPieChartComponent,IgDoughnutChartComponent,IgFunnelChartComponent,IgRadialGaugeComponent,IgZoombarComponent,IgMapComponent,IgSparklineComponent,IgBulletGraphComponent,IgLinearGaugeComponent,IgQRCodeBarcodeComponent,IgUploadComponent,IgPopoverComponent,IgNotifierComponent,IgRatingComponent,IgVideoPlayerComponent,IgRadialMenuComponent,IgSplitButtonComponent, IgSpreadsheetComponent, IgSchedulerComponent]
56965755
})
56975756
export class IgniteUIModule {}

tests/unit/iggrid/grid.spec.ts

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@ export function main() {
88

99
beforeEach(() => {
1010
TestBed.configureTestingModule({
11-
declarations: [Infragistics.Column, Infragistics.Features, Infragistics.IgGridPagingFeature, Infragistics.IgGridComponent, TestComponent]
11+
declarations: [Infragistics.Column, Infragistics.Features, Infragistics.IgGridPagingFeature, Infragistics.IgGridComponent,
12+
Infragistics.IgGridCellMergingFeature, Infragistics.IgGridAppendRowsOnDemandFeature, Infragistics.IgGridColumnFixingFeature,
13+
Infragistics.IgGridColumnMovingFeature, Infragistics.IgGridFilteringFeature, Infragistics.IgGridGroupByFeature,
14+
Infragistics.IgGridHidingFeature, Infragistics.IgGridHidingFeature, Infragistics.IgGridMultiColumnHeadersFeature,
15+
Infragistics.IgGridResizingFeature, Infragistics.IgGridResponsiveFeature, Infragistics.IgGridRowSelectorsFeature,
16+
Infragistics.IgGridSelectionFeature, Infragistics.IgGridSortingFeature, Infragistics.IgGridSummariesFeature,
17+
Infragistics.IgGridTooltipsFeature, Infragistics.IgGridUpdatingFeature, TestComponent]
1218
});
1319
});
1420

@@ -354,6 +360,93 @@ export function main() {
354360
});
355361
});
356362

363+
it('should initialize grid features', (done) => {
364+
var template = "<ig-grid [widgetId]='gridID' [width]='w' [autoCommit]='true' [dataSource]='data' [height]='h' [autoGenerateColumns]='false' [primaryKey]='\"Id\"'>" +
365+
"<column [key]=\"'Id'\" [(headerText)]=\"idHeaderText\" [width]=\"'165px'\" [dataType]=\"'number'\"></column>" +
366+
"<column [key]=\"'Name'\" [headerText]=\"'Name'\" [width]=\"'250px'\" [dataType]=\"'string'\"></column>" +
367+
"<column [key]=\"'HireDate'\" [headerText]=\"'Quantity per unit'\" [width]=\"'250px'\" [dataType]=\"'date'\"></column>" +
368+
"<features>" +
369+
"<paging [(currentPageIndex)]=\"pi\" [pageSize]=\"'2'\"> </paging>" +
370+
"<sorting></sorting><filtering></filtering><hiding></hiding><group-by></group-by>" +
371+
"<column-moving></column-moving><cell-merging></cell-merging><multi-column-headers></multi-column-headers>" +
372+
"<summaries></summaries>" +
373+
"</features>" +
374+
"</ig-grid>";
375+
TestBed.overrideComponent(TestComponent, {
376+
set: {
377+
template: template
378+
}
379+
});
380+
TestBed.compileComponents().then(() => {
381+
let fixture = TestBed.createComponent(TestComponent), $grid;
382+
fixture.detectChanges();
383+
$grid = $("#grid1");
384+
expect($grid.data("igGridPaging") !== undefined).toBeTruthy("Paging feature not initialized");
385+
expect($grid.data("igGridSorting") !== undefined).toBeTruthy("Sorting feature not initialized");
386+
expect($grid.data("igGridFiltering") !== undefined).toBeTruthy("Filtering feature not initialized");
387+
expect($grid.data("igGridHiding") !== undefined).toBeTruthy("Hiding feature not initialized");
388+
expect($grid.data("igGridGroupBy") !== undefined).toBeTruthy("GroupBy feature not initialized");
389+
expect($grid.data("igGridColumnMoving") !== undefined).toBeTruthy("Column Moving feature not initialized");
390+
expect($grid.data("igGridCellMerging") !== undefined).toBeTruthy("Cell Merging feature not initialized");
391+
expect($grid.data("igGridMultiColumnHeaders") !== undefined).toBeTruthy("Multi Column Headers feature not initialized");
392+
expect($grid.data("igGridSummaries") !== undefined).toBeTruthy("Summaries feature not initialized");
393+
done();
394+
});
395+
});
396+
397+
it('should initialize grid features 2', (done) => {
398+
var template = "<ig-grid [widgetId]='gridID' [width]='gridWidth' [autoCommit]='true' [dataSource]='data' [height]='h' [autoGenerateColumns]='false' [primaryKey]='\"Id\"'>" +
399+
"<column [key]=\"'Id'\" [(headerText)]=\"idHeaderText\" [width]=\"'165px'\" [dataType]=\"'number'\"></column>" +
400+
"<column [key]=\"'Name'\" [headerText]=\"'Name'\" [width]=\"'250px'\" [dataType]=\"'string'\"></column>" +
401+
"<column [key]=\"'HireDate'\" [headerText]=\"'Quantity per unit'\" [width]=\"'250px'\" [dataType]=\"'date'\"></column>" +
402+
"<features>" +
403+
"<column-fixing></column-fixing><selection></selection><row-selectors></row-selectors><updating></updating><tooltips></tooltips>" +
404+
"</features>" +
405+
"</ig-grid>";
406+
TestBed.overrideComponent(TestComponent, {
407+
set: {
408+
template: template
409+
}
410+
});
411+
TestBed.compileComponents().then(() => {
412+
let fixture = TestBed.createComponent(TestComponent), $grid;
413+
fixture.detectChanges();
414+
fixture.componentInstance.gridWidth = "400px";
415+
$grid = $("#grid1");
416+
expect($grid.data("igGridColumnFixing") !== undefined).toBeTruthy("Column Fixing feature not initialized");
417+
expect($grid.data("igGridSelection") !== undefined).toBeTruthy("Selection feature not initialized");
418+
expect($grid.data("igGridRowSelectors") !== undefined).toBeTruthy("Row Selectors feature not initialized");
419+
expect($grid.data("igGridUpdating") !== undefined).toBeTruthy("Updating feature not initialized");
420+
expect($grid.data("igGridTooltips") !== undefined).toBeTruthy("Tooltips feature not initialized");
421+
done();
422+
});
423+
});
424+
425+
it('should initialize grid features 3', (done) => {
426+
var template = "<ig-grid [widgetId]='gridID' [width]='gridWidth' [autoCommit]='true' [dataSource]='data' [height]='400' [autoGenerateColumns]='false' [primaryKey]='\"Id\"'>" +
427+
"<column [key]=\"'Id'\" [(headerText)]=\"idHeaderText\" [width]=\"'165px'\" [dataType]=\"'number'\"></column>" +
428+
"<column [key]=\"'Name'\" [headerText]=\"'Name'\" [width]=\"'250px'\" [dataType]=\"'string'\"></column>" +
429+
"<column [key]=\"'HireDate'\" [headerText]=\"'Quantity per unit'\" [width]=\"'250px'\" [dataType]=\"'date'\"></column>" +
430+
"<features>" +
431+
"<append-rows-on-demand></append-rows-on-demand><responsive></responsive>" +
432+
"</features>" +
433+
"</ig-grid>";
434+
TestBed.overrideComponent(TestComponent, {
435+
set: {
436+
template: template
437+
}
438+
});
439+
TestBed.compileComponents().then(() => {
440+
let fixture = TestBed.createComponent(TestComponent), $grid;
441+
fixture.detectChanges();
442+
fixture.componentInstance.gridWidth = "400px";
443+
$grid = $("#grid1");
444+
expect($grid.data("igGridAppendRowsOnDemand") !== undefined).toBeTruthy("Append Rows On Demand feature not initialized");
445+
expect($grid.data("igGridResponsive") !== undefined).toBeTruthy("Responsive feature not initialized");
446+
done();
447+
});
448+
});
449+
357450
it('should initialize column and feature nested directives', (done) => {
358451
var template = "<ig-grid [widgetId]='gridID' [width]='w' [autoCommit]='true' [dataSource]='data' [height]='h' [autoGenerateColumns]='false' [primaryKey]='\"Id\"'>" +
359452
"<column [key]=\"'Id'\" [(headerText)]=\"idHeaderText\" [width]=\"'165px'\" [dataType]=\"'number'\"></column>" +
@@ -551,6 +644,7 @@ class TestComponent {
551644
private firedEvent: any;
552645
public caption: string;
553646
public idHeaderText: string;
647+
public gridWidth: string;
554648
@ViewChild(Infragistics.IgGridComponent) public viewChild: Infragistics.IgGridComponent;
555649

556650
constructor() {
@@ -559,6 +653,7 @@ class TestComponent {
559653
this.caption = "My Caption";
560654
this.idHeaderText = "Product Id";
561655
this.pi = 1;
656+
this.gridWidth = "800px";
562657
this.data = [
563658
{ "Id": 1, "Name": "John Smith", "Age": 45, "HireDate": "2002-05-09" },
564659
{ "Id": 2, "Name": "Mary Johnson", "Age": 32, "HireDate": "2004-01-18" },

0 commit comments

Comments
 (0)