Skip to content

Commit 2860d69

Browse files
committed
Adding test for each feature.
Adding test for each feature.
1 parent 69accbd commit 2860d69

File tree

2 files changed

+158
-6
lines changed

2 files changed

+158
-6
lines changed

src/iggrid/features.directive.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export class Features implements AfterContentInit {
2828
@ContentChild(IgGridPagingFeature) paging: IgGridPagingFeature;
2929
@ContentChild(IgGridUpdatingFeature) updating: IgGridUpdatingFeature;
3030
@ContentChild(IgGridGroupByFeature) groupBy: IgGridGroupByFeature;
31-
@ContentChild(IgGridColumnMovingFeature) moving: IgGridColumnMovingFeature;
31+
@ContentChild(IgGridColumnMovingFeature) columnMoving: IgGridColumnMovingFeature;
3232
@ContentChild(IgGridHidingFeature) hiding: IgGridHidingFeature;
3333
@ContentChild(IgGridCellMergingFeature) cellMerging: IgGridCellMergingFeature;
3434
@ContentChild(IgGridResponsiveFeature) responsive: IgGridResponsiveFeature;
@@ -53,7 +53,7 @@ export class Features implements AfterContentInit {
5353
case "paging": this.paging = new IgGridPagingFeature(child); break;
5454
case "updating": this.updating = new IgGridUpdatingFeature(child); break;
5555
case "group-by": this.groupBy = new IgGridGroupByFeature(child); break;
56-
case "moving": this.moving = new IgGridColumnMovingFeature(child); break;
56+
case "column-moving": this.columnMoving = new IgGridColumnMovingFeature(child); break;
5757
case "hiding": this.hiding = new IgGridHidingFeature(child); break;
5858
case "responsive": this.responsive = new IgGridResponsiveFeature(child); break;
5959
case "cell-merging": this.cellMerging = new IgGridCellMergingFeature(child); break;
@@ -76,7 +76,7 @@ export class Features implements AfterContentInit {
7676
this.paging ? this.allFeatures.push(this.paging): null;
7777
this.updating ? this.allFeatures.push(this.updating): null;
7878
this.groupBy ? this.allFeatures.push(this.groupBy): null;
79-
this.moving ? this.allFeatures.push(this.moving): null;
79+
this.columnMoving ? this.allFeatures.push(this.columnMoving): null;
8080
this.hiding ? this.allFeatures.push(this.hiding): null;
8181
this.responsive ? this.allFeatures.push(this.responsive): null;
8282
this.cellMerging ? this.allFeatures.push(this.cellMerging): null;

tests/unit/iggrid/grid.spec.ts

Lines changed: 155 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ export function main() {
625625
});
626626
});
627627
it('should populate featuerList when features are defined via grid options.', (done) => {
628-
var template = '<div><ig-grid [(widgetId)]="gridID" [(options)]="opts1" [(dataSource)]="data1"></ig-grid></div>';
628+
var template = '<div><ig-grid [(widgetId)]="gridID" [(options)]="optsAllFeatures" [(dataSource)]="data1"></ig-grid></div>';
629629
TestBed.overrideComponent(TestComponent, {
630630
set: {
631631
template: template
@@ -635,11 +635,57 @@ export function main() {
635635
let fixture = TestBed.createComponent(TestComponent);
636636
fixture.detectChanges();
637637
var list = fixture.componentInstance.viewChild.featuresList;
638-
expect(list.allFeatures.length).toBe(1);
638+
expect(list.allFeatures.length).toBe(14);
639639
expect(list.updating !== undefined).toBeTruthy("Feature should be populated.");
640+
expect(list.filtering !== undefined).toBeTruthy("Feature should be populated.");
641+
expect(list.paging !== undefined).toBeTruthy("Feature should be populated.");
642+
expect(list.columnFixing !== undefined).toBeTruthy("Feature should be populated.");
643+
expect(list.columnMoving !== undefined).toBeTruthy("Feature should be populated.");
644+
expect(list.sorting !== undefined).toBeTruthy("Feature should be populated.");
645+
expect(list.tooltips !== undefined).toBeTruthy("Feature should be populated.");
646+
expect(list.cellMerging !== undefined).toBeTruthy("Feature should be populated.");
647+
expect(list.selection !== undefined).toBeTruthy("Feature should be populated.");
648+
expect(list.rowSelectors !== undefined).toBeTruthy("Feature should be populated.");
649+
expect(list.resizing !== undefined).toBeTruthy("Feature should be populated.");
650+
expect(list.multiColumnHeaders !== undefined).toBeTruthy("Feature should be populated.");
651+
expect(list.columnFixing !== undefined).toBeTruthy("Feature should be populated.");
652+
expect(list.summaries !== undefined).toBeTruthy("Feature should be populated.");
640653
done();
641654
});
655+
});
642656

657+
it('should populate featuerList when features are defined via grid options - part 2.', (done) => {
658+
var template = '<div><ig-grid [(widgetId)]="gridID" [(options)]="optsAllFeatures2" [(dataSource)]="data1"></ig-grid></div>';
659+
TestBed.overrideComponent(TestComponent, {
660+
set: {
661+
template: template
662+
}
663+
});
664+
TestBed.compileComponents().then(() => {
665+
let fixture = TestBed.createComponent(TestComponent);
666+
fixture.detectChanges();
667+
var list = fixture.componentInstance.viewChild.featuresList;
668+
expect(list.allFeatures.length).toBe(2);
669+
expect(list.appendRowsOnDemand !== undefined).toBeTruthy("Feature should be populated.");
670+
expect(list.responsive !== undefined).toBeTruthy("Feature should be populated.");
671+
done();
672+
});
673+
});
674+
it('should populate featuerList when features are defined via grid options - part 3.', (done) => {
675+
var template = '<div><ig-grid [(widgetId)]="gridID" [(options)]="optsAllFeatures3" [(dataSource)]="data1"></ig-grid></div>';
676+
TestBed.overrideComponent(TestComponent, {
677+
set: {
678+
template: template
679+
}
680+
});
681+
TestBed.compileComponents().then(() => {
682+
let fixture = TestBed.createComponent(TestComponent);
683+
fixture.detectChanges();
684+
var list = fixture.componentInstance.viewChild.featuresList;
685+
expect(list.allFeatures.length).toBe(1);
686+
expect(list.groupBy !== undefined).toBeTruthy("Feature should be populated.");
687+
done();
688+
});
643689
});
644690
});
645691
}
@@ -662,6 +708,9 @@ class TestComponent {
662708
public caption: string;
663709
public idHeaderText: string;
664710
public gridWidth: string;
711+
public optsAllFeatures:any;
712+
public optsAllFeatures2:any;
713+
public optsAllFeatures3:any;
665714
@ViewChild(Infragistics.IgGridComponent) public viewChild: Infragistics.IgGridComponent;
666715

667716
constructor() {
@@ -734,7 +783,110 @@ class TestComponent {
734783
}
735784
]
736785
};
737-
}
786+
787+
this.optsAllFeatures = {
788+
width: "700px",
789+
height: "400px",
790+
autoCommit: true,
791+
autoGenerateColumns: false,
792+
columns: [
793+
{ key: "Id", headerText: "ID", width: "100px", dataType: "string" },
794+
{ key: "Date", headerText: "Date", dataType: "date", width: "100px", format: "dd/MM/yyyy" },
795+
],
796+
primaryKey: "Id",
797+
features: [
798+
{
799+
name: "Filtering"
800+
},
801+
{
802+
name: "Updating"
803+
},
804+
{
805+
name: "Paging"
806+
},
807+
{
808+
name: "ColumnFixing"
809+
},
810+
{
811+
name: "Sorting"
812+
},
813+
{
814+
name: "Summaries"
815+
},
816+
{
817+
name: "Hiding"
818+
},
819+
{
820+
name: "ColumnMoving"
821+
},
822+
{
823+
name: "Tooltips"
824+
},
825+
{
826+
name: "CellMerging"
827+
},
828+
{
829+
name: "Selection"
830+
},
831+
{
832+
name: "RowSelectors"
833+
},
834+
//{
835+
//name: "AppendRowsOnDemand"
836+
//},
837+
//{
838+
//name: "GroupBy"
839+
//},
840+
{
841+
name: "Resizing"
842+
},
843+
{
844+
name: "MultiColumnHeaders"
845+
},
846+
//{
847+
// name: "Responsive"
848+
//}
849+
]
850+
};
851+
this.optsAllFeatures2 = {
852+
width: "700px",
853+
height: "400px",
854+
autoCommit: true,
855+
autoGenerateColumns: false,
856+
columns: [
857+
{ key: "Id", headerText: "ID", width: "100px", dataType: "string" },
858+
{ key: "Date", headerText: "Date", dataType: "date", width: "100px", format: "dd/MM/yyyy" },
859+
],
860+
primaryKey: "Id",
861+
features: [
862+
{
863+
name: "AppendRowsOnDemand"
864+
},
865+
{
866+
name: "Responsive"
867+
}
868+
]
869+
};
870+
871+
this.optsAllFeatures3 = {
872+
width: "700px",
873+
height: "400px",
874+
autoCommit: true,
875+
autoGenerateColumns: false,
876+
columns: [
877+
{ key: "Id", headerText: "ID", width: "100px", dataType: "string" },
878+
{ key: "Date", headerText: "Date", dataType: "date", width: "100px", format: "dd/MM/yyyy" },
879+
],
880+
primaryKey: "Id",
881+
features: [
882+
{
883+
name:"GroupBy"
884+
}
885+
]
886+
};
887+
888+
};
889+
738890

739891
public cellClickHandler(evt) {
740892
this.firedEvent = evt;

0 commit comments

Comments
 (0)