add is operand on number field (#16022)
Co-authored-by: martmull <martmull@hotmail.fr>
This commit is contained in:
+10
@@ -474,6 +474,16 @@ describe('evaluateFilterConditions', () => {
|
||||
expect(evaluateFilterConditions({ filters: [filter2] })).toBe(true);
|
||||
expect(evaluateFilterConditions({ filters: [filter3] })).toBe(false);
|
||||
});
|
||||
|
||||
it('should handle Is operand correctly', () => {
|
||||
const filter1 = createFilter(ViewFilterOperand.IS, 25, 25, 'NUMBER');
|
||||
const filter2 = createFilter(ViewFilterOperand.IS, 20, 25, 'NUMBER');
|
||||
const filter3 = createFilter(ViewFilterOperand.IS, 30, 25, 'NUMBER');
|
||||
|
||||
expect(evaluateFilterConditions({ filters: [filter1] })).toBe(true);
|
||||
expect(evaluateFilterConditions({ filters: [filter2] })).toBe(false);
|
||||
expect(evaluateFilterConditions({ filters: [filter3] })).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('string and array operands', () => {
|
||||
|
||||
+3
@@ -319,6 +319,9 @@ function evaluateNumberFilter(filter: ResolvedFilter): boolean {
|
||||
case ViewFilterOperand.IS_NOT_EMPTY:
|
||||
return isNonEmptyString(leftValue);
|
||||
|
||||
case ViewFilterOperand.IS:
|
||||
return Number(leftValue) === Number(rightValue);
|
||||
|
||||
default:
|
||||
throw new Error(
|
||||
`Operand ${filter.operand} not supported for number filter`,
|
||||
|
||||
Reference in New Issue
Block a user