Skip to content

Commit c05b173

Browse files
committed
Add test for column and feature nested directives
1 parent ac53ff0 commit c05b173

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

tests/unit/iggrid/grid.spec.ts

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,28 +217,63 @@ export function main() {
217217
});
218218
})();
219219
});
220+
221+
it('should initialize column and feature nested directives', (done) => {
222+
inject([TestComponentBuilder], (tcb: TestComponentBuilder) => {
223+
var template = "<ig-grid [widgetId]='gridID' [width]='w' [autoCommit]='true' [dataSource]='data' [height]='h' [autoGenerateColumns]='false' [primaryKey]='\"Id\"'>" +
224+
"<column [key]=\"'Id'\" [(headerText)]=\"idHeaderText\" [width]=\"'165px'\" [dataType]=\"'number'\"></column>" +
225+
"<column [key]=\"'Name'\" [headerText]=\"'Name'\" [width]=\"'250px'\" [dataType]=\"'string'\"></column>" +
226+
"<column [key]=\"'HireDate'\" [headerText]=\"'Quantity per unit'\" [width]=\"'250px'\" [dataType]=\"'date'\"></column>" +
227+
"<feature [name]=\"'Paging'\" [(currentPageIndex)]=\"pi\" [pageSize]=\"'2'\"></feature>" +
228+
"</ig-grid>";
229+
return tcb.overrideTemplate(TestComponent, template)
230+
.createAsync(TestComponent)
231+
.then((fixture) => {
232+
fixture.detectChanges();
233+
expect($(fixture.debugElement.nativeElement).find("#grid1 thead th#grid1_Id").text())
234+
.toBe("Product Id");
235+
expect($(fixture.debugElement.nativeElement).find("#grid1_pager li.ui-state-active").text())
236+
.toBe("2");
237+
fixture.componentInstance.pi = 0;
238+
fixture.componentInstance.idHeaderText = "Changed ID";
239+
setTimeout(() => {
240+
fixture.detectChanges();
241+
//this assert should wait the next Service Release of IgniteUI
242+
//expect($(fixture.debugElement.nativeElement).find("#grid1 thead th#grid1_Id").text())
243+
// .toBe("Changed ID");
244+
expect($(fixture.debugElement.nativeElement).find("#grid1_pager li.ui-state-active").text())
245+
.toBe("1");
246+
done();
247+
}, 10);
248+
});
249+
})();
250+
});
220251
});
221252
}
222253

223254
@Component({
224255
selector: 'test-cmp',
225256
template: '<div></div>', //"Component 'TestComponent' must have either 'template' or 'templateUrl' set."
226-
directives: [Infragistics.IgGridComponent]
257+
directives: [Infragistics.Column, Infragistics.Feature, Infragistics.IgGridComponent]
227258
})
228259
class TestComponent {
229260
private opts: any;
230261
public opts1: any;
231262
private gridID: string;
232263
public data: Array<any>;
233264
private cdi: number;
265+
public pi: number;
234266
private firedEvent: any;
235267
public caption: string;
268+
public idHeaderText: string;
236269
@ViewChild(Infragistics.IgGridComponent) public viewChild: Infragistics.IgGridComponent;
237270

238271
constructor() {
239272
this.gridID = "grid1";
240273
this.cdi = 0;
241274
this.caption = "My Caption";
275+
this.idHeaderText = "Product Id";
276+
this.pi = 1;
242277
this.data = [
243278
{ "Id": 1, "Name": "John Smith", "Age": 45, "HireDate": "\/Date(704678400000)\/" },
244279
{ "Id": 2, "Name": "Mary Johnson", "Age": 32, "HireDate": "\/Date(794678400000)\/" },

0 commit comments

Comments
 (0)