Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,29 @@ describe('Unit testing FilteringStrategy', () => {
const res = fs.matchRecord(rec, expressionTree);
expect(res).toBeTruthy();
});

it ('tests `findMatchByExpression` for working with filtering operands with missing condition', () => {
const rec = data[0];
const expressionTree = JSON.parse('{"filteringOperands":[{"fieldName":"Missing","condition":{"name":"notEmpty","isUnary":true,"iconName":"filter_not_empty"},"conditionName":"notEmpty","ignoreCase":true,"searchVal":null,"searchTree":null}],"operator":0,"returnFields":[],"type":1}');
const res = fs.matchRecord(rec, expressionTree);
expect(res).toBeFalsy();
});

it ('no error when condition is missing in the filtering expressions tree', () => {
const rec = data[0];
const expressionTree = new FilteringExpressionsTree(FilteringLogic.Or);
expressionTree.filteringOperands = [
{
conditionName: 'contains',
fieldName: 'string',
ignoreCase: false,
searchVal: 'ROW'
}
];
const res = fs.matchRecord(rec, expressionTree);
expect(res).toBeFalsy();
});

it ('tests `findMatch`', () => {
const rec = data[0];
const res = fs.findMatchByExpression(rec, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,10 @@ export interface IgxFilterItem {
export abstract class BaseFilteringStrategy implements IFilteringStrategy {
// protected
public findMatchByExpression(rec: any, expr: IFilteringExpression, isDate?: boolean, isTime?: boolean, grid?: GridType): boolean {
const cond = expr.condition;
const val = this.getFieldValue(rec, expr.fieldName, isDate, isTime, grid);
return cond.logic(val, expr.searchVal, expr.ignoreCase);
if (expr.condition?.logic) {
return expr.condition.logic(val, expr.searchVal, expr.ignoreCase);
}
}

// protected
Expand Down
Loading