Enhance date range filter input mapping with min/max value handling.

-  **Feature**: Added mapping for min and max values in date range input
- 🛠️ **Refactor**: Updated handling of optional min/max properties in mapping function
- 🧪 **Test**: Added unit test for min and max value mapping
This commit is contained in:
Lorenz Hilpert
2025-04-11 16:54:59 +02:00
parent e04d88f2ce
commit 3c43d50f0f
2 changed files with 51 additions and 2 deletions

View File

@@ -125,4 +125,53 @@ describe('dateRangeFilterInputMapping', () => {
stop: undefined,
});
});
it('should map min and max values correctly', () => {
// Arrange
const group = 'testGroup';
const input: Input = {
key: 'testKey',
label: 'Test Label',
type: InputType.DateRange,
options: {
values: [
{
label: 'Start',
value: '2023-01-01',
minValue: '2022-01-01',
maxValue: '2024-12-31',
},
{ label: 'End', value: '2023-12-31' },
],
},
};
// Act
const result = dateRangeFilterInputMapping(group, input);
// Assert
expect(mockSchemaParser).toHaveBeenCalledWith({
group: 'testGroup',
key: 'testKey',
label: 'Test Label',
description: undefined,
type: InputType.DateRange,
start: '2023-01-01',
stop: '2023-12-31',
minStrat: '2022-01-01',
maxStop: '2024-12-31',
});
expect(result).toEqual({
group: 'testGroup',
key: 'testKey',
label: 'Test Label',
description: undefined,
type: InputType.DateRange,
start: '2023-01-01',
stop: '2023-12-31',
minStrat: '2022-01-01',
maxStop: '2024-12-31',
});
});
});

View File

@@ -24,7 +24,7 @@ export function dateRangeFilterInputMapping(
type: InputType.DateRange,
start: input.options?.values?.[0]?.value,
stop: input.options?.values?.[1]?.value,
minStart: input.options?.values?.[0].minValue,
maxStart: input.options?.values?.[0].maxValue,
minStart: input.options?.values?.[0]?.minValue,
maxStop: input.options?.values?.[0]?.maxValue,
});
}