Skip to content

Commit 81fdcf6

Browse files
committed
test(Filtering): Adding a test for a declared IExpressionTree object.
1 parent 9694356 commit 81fdcf6

File tree

2 files changed

+54
-16
lines changed

2 files changed

+54
-16
lines changed

projects/igniteui-angular/src/lib/grids/grid/grid-filtering-advanced.spec.ts

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,7 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
13931393

13941394
});
13951395

1396-
describe('Expression tree serialization - ', () => {
1396+
describe('Expression tree rehydration - ', () => {
13971397
it('should correctly filter with a deserialized expression tree.', fakeAsync(() => {
13981398
const errorSpy = spyOn(console, 'error');
13991399
let fix = TestBed.createComponent(IgxGridAdvancedFilteringSerializedTreeComponent);
@@ -1406,6 +1406,36 @@ describe('IgxGrid - Advanced Filtering #grid - ', () => {
14061406
expect(grid.filteredData.length).toEqual(3);
14071407
expect(grid.rowList.length).toBe(3);
14081408
}));
1409+
1410+
it('should correctly filter with a declared IFilteringExpressionsTree object.', fakeAsync(() => {
1411+
const errorSpy = spyOn(console, 'error');
1412+
let fix = TestBed.createComponent(IgxGridAdvancedFilteringSerializedTreeComponent);
1413+
fix.detectChanges();
1414+
fix.componentInstance.grid.advancedFilteringExpressionsTree = fix.componentInstance.filterTreeObject;
1415+
fix.detectChanges();
1416+
let grid = fix.componentInstance.grid;
1417+
1418+
expect(errorSpy).not.toHaveBeenCalled();
1419+
1420+
// Verify filtered data
1421+
expect(grid.filteredData.length).toEqual(2);
1422+
expect(grid.rowList.length).toBe(2);
1423+
}));
1424+
1425+
xit('should correctly filter when binding to a declared IFilteringExpressionsTree object.', fakeAsync(() => {
1426+
const errorSpy = spyOn(console, 'error');
1427+
let fix = TestBed.createComponent(IgxGridAdvancedFilteringSerializedTreeComponent);
1428+
fix.detectChanges();
1429+
fix.componentInstance.filterTree = fix.componentInstance.filterTreeObject;
1430+
fix.detectChanges();
1431+
let grid = fix.componentInstance.grid;
1432+
1433+
expect(errorSpy).not.toHaveBeenCalled();
1434+
1435+
// Verify filtered data
1436+
expect(grid.filteredData.length).toEqual(2);
1437+
expect(grid.rowList.length).toBe(2);
1438+
}));
14091439
});
14101440
});
14111441

projects/igniteui-angular/src/lib/test-utils/grid-samples.spec.ts

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2092,6 +2092,7 @@ export class IgxGridAdvancedFilteringSerializedTreeComponent extends BasicGridCo
20922092
public resizable = false;
20932093
public filterable = true;
20942094
public filterTree: IFilteringExpressionsTree;
2095+
public filterTreeObject: IFilteringExpressionsTree;
20952096

20962097
public override data = SampleTestData.excelFilteringData();
20972098

@@ -2106,21 +2107,28 @@ export class IgxGridAdvancedFilteringSerializedTreeComponent extends BasicGridCo
21062107
],
21072108
"operator": 0
21082109
}`);
2109-
// this.filterTree = JSON.parse(`{
2110-
// "filteringOperands": [
2111-
// {
2112-
// "conditionName": "greaterThan",
2113-
// "condition":{
2114-
// "name":"greaterThan",
2115-
// "isUnary":false,
2116-
// "iconName":"filter_greater_than"
2117-
// },
2118-
// "fieldName": "Downloads",
2119-
// "searchVal": 200
2120-
// }
2121-
// ],
2122-
// "operator": 0
2123-
// }`);
2110+
2111+
this.filterTreeObject = {
2112+
"filteringOperands": [
2113+
{
2114+
"fieldName": "ProductName",
2115+
"condition": {
2116+
"name": "contains",
2117+
"isUnary": false,
2118+
"iconName": "filter_contains"
2119+
},
2120+
"conditionName": "contains",
2121+
"ignoreCase": true,
2122+
"searchVal": "Ig",
2123+
"searchTree": null
2124+
}
2125+
],
2126+
"operator": 1,
2127+
"returnFields": [
2128+
"ID",
2129+
"ProductName"
2130+
]
2131+
};
21242132
}
21252133
}
21262134

0 commit comments

Comments
 (0)