mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
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:
@@ -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',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user