Skip to content

Commit c75d24c

Browse files
committed
Fixing Tree and TreeGrid tests.
1 parent 238f662 commit c75d24c

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

src/igtreegrid/igtreegrid.component.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,15 @@ export class IgTreeGridComponent extends IgGridBase<IgTreeGrid> {
4040
} else {
4141
super.updateRow(rec, currValue, key);
4242
}
43-
}
43+
}
44+
45+
public markForCheck(){
46+
super.markForCheck();
47+
const childDataKey = this["childDataKey"] || this.options.childDataKey;
48+
if (childDataKey) {
49+
this.dataBind();
50+
}
51+
}
4452

4553
/**
4654
* Clears the transaction log (delegates to igDataSource). Note that this does not update the UI. In case the UI must be updated, set the second parameter "updateUI" to true, which will trigger a call to dataBind() to re-render the contents.

tests/unit/igtree/igtree.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function main() {
1414
});
1515

1616
it('should initialize correctly', (done) => {
17-
var template = '<div><ig-tree [(widgetId)]="treeID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree></div>';
17+
var template = '<div><ig-tree [(widgetId)]="treeID" [(options)]="opts" [dataSource]="data"></ig-tree></div>';
1818
TestBed.overrideComponent(TestComponent, {
1919
set: {
2020
template: template
@@ -30,7 +30,7 @@ export function main() {
3030
});
3131

3232
it('should reflect changes when a record in the data changes', (done) => {
33-
var template = '<div><ig-tree [(widgetId)]="treeID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree></div>';
33+
var template = '<div><ig-tree [(widgetId)]="treeID" [(options)]="opts" [dataSource]="data"></ig-tree></div>';
3434
TestBed.overrideComponent(TestComponent, {
3535
set: {
3636
template: template
@@ -50,7 +50,7 @@ export function main() {
5050
});
5151

5252
it('should reflect changes when a record is added/removed from the data', (done) => {
53-
var template = '<div><ig-tree [(widgetId)]="treeID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree></div>';
53+
var template = '<div><ig-tree [(widgetId)]="treeID" [(options)]="opts" [dataSource]="data"></ig-tree></div>';
5454
TestBed.overrideComponent(TestComponent, {
5555
set: {
5656
template: template
@@ -122,7 +122,7 @@ class TestComponent {
122122
this.data = ProductCategories.getData();
123123

124124
this.opts = {
125-
dataSource: this.data,
125+
//dataSource: this.data,
126126
bindings: {
127127
childDataProperty: "ProductSubcategories",
128128
textKey: "Name",

tests/unit/igtreegrid/treegrid.spec.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function main() {
1414
});
1515

1616
it('should initialize correctly', (done) => {
17-
var template = '<div><ig-tree-grid [(widgetId)]="gridID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree-grid></div>';
17+
var template = '<div><ig-tree-grid [(widgetId)]="gridID" [(options)]="opts" [dataSource]="data"></ig-tree-grid></div>';
1818
TestBed.overrideComponent(TestComponent, {
1919
set: {
2020
template: template
@@ -30,7 +30,7 @@ export function main() {
3030
});
3131

3232
it('should reflect changes when a record in the data changes', (done) => {
33-
var template = '<div><ig-tree-grid [(widgetId)]="gridID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree-grid></div>';
33+
var template = '<div><ig-tree-grid [(widgetId)]="gridID" [(options)]="opts" [dataSource]="data"></ig-tree-grid></div>';
3434
TestBed.overrideComponent(TestComponent, {
3535
set: {
3636
template: template
@@ -39,6 +39,8 @@ export function main() {
3939
TestBed.compileComponents().then(() => {
4040
let fixture = TestBed.createComponent(TestComponent);
4141
fixture.detectChanges();
42+
fixture.componentInstance.data[0].tasks = "";
43+
fixture.detectChanges();
4244
fixture.componentInstance.data[0].tasks = "Test";
4345
fixture.detectChanges();
4446
setTimeout(() => {
@@ -51,7 +53,7 @@ export function main() {
5153
});
5254

5355
it('should reflect changes when a record is added/removed from the data', (done) => {
54-
var template = '<div><ig-tree-grid [(widgetId)]="gridID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree-grid></div>';
56+
var template = '<div><ig-tree-grid [(widgetId)]="gridID" [(options)]="opts" [dataSource]="data"></ig-tree-grid></div>';
5557
TestBed.overrideComponent(TestComponent, {
5658
set: {
5759
template: template
@@ -62,6 +64,8 @@ export function main() {
6264
fixture.detectChanges();
6365
//remove item
6466
fixture.componentInstance.data[0].products.removeAt(4);
67+
68+
fixture.componentInstance.viewChild.markForCheck();
6569

6670
setTimeout(() => {
6771
fixture.detectChanges();
@@ -83,7 +87,7 @@ export function main() {
8387
});
8488

8589
it('should reflect changes when the root record is removed', (done) => {
86-
var template = '<div><ig-tree-grid [(widgetId)]="gridID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree-grid></div>';
90+
var template = '<div><ig-tree-grid [(widgetId)]="gridID" [(options)]="opts" [dataSource]="data"></ig-tree-grid></div>';
8791
TestBed.overrideComponent(TestComponent, {
8892
set: {
8993
template: template
@@ -105,7 +109,7 @@ export function main() {
105109
});
106110

107111
it('should reflect changes when records in the treegrid are updated/added/deleted', (done) => {
108-
var template = '<div><ig-tree-grid [(widgetId)]="gridID" [(options)]="opts" [changeDetectionInterval]="cdi"></ig-tree-grid></div>';
112+
var template = '<div><ig-tree-grid [(widgetId)]="gridID" [(options)]="opts" [dataSource]="data"></ig-tree-grid></div>';
109113
TestBed.overrideComponent(TestComponent, {
110114
set: {
111115
template: template
@@ -114,7 +118,6 @@ export function main() {
114118
TestBed.compileComponents().then(() => {
115119
let fixture = TestBed.createComponent(TestComponent);
116120
fixture.detectChanges();
117-
118121
//update row
119122
$("#grid1").igTreeGridUpdating("updateRow", 0, { tasks: "Updated Plan" });
120123
setTimeout(() => {
@@ -163,7 +166,7 @@ export function main() {
163166

164167

165168
it("should detect changes when original data source is changed but the data source length is the same.", (done) => {
166-
var template = '<ig-tree-grid [(widgetId)]="gridID" [(options)]="optsNew"></ig-tree-grid>';
169+
var template = '<ig-tree-grid [(widgetId)]="gridID" [(options)]="optsNew" [dataSource]="singleRecData"></ig-tree-grid>';
167170
TestBed.overrideComponent(TestComponent, {
168171
set: {
169172
template: template
@@ -207,7 +210,7 @@ class TestComponent {
207210
this.singleRecData2 = [{ "id": 1, "tasks": "Test" }];
208211
this.opts = {
209212
autoCommit: true,
210-
dataSource: this.data,
213+
//dataSource: this.data,
211214
width: "100%",
212215
height: "400px",
213216
autoGenerateColumns: false,

0 commit comments

Comments
 (0)