diff --git a/src/shared/ui/survey/DatePickerItem.tsx b/src/shared/ui/survey/DatePickerItem.tsx index 39a7d0b74..f9de47c78 100644 --- a/src/shared/ui/survey/DatePickerItem.tsx +++ b/src/shared/ui/survey/DatePickerItem.tsx @@ -1,4 +1,4 @@ -import { FC, useMemo } from 'react'; +import { FC } from 'react'; import { format } from 'date-fns'; @@ -21,13 +21,7 @@ const DatePickerItem: FC = ({ value, onChange }) => { onChange(formattedDate); }; - const valueAsDate = useMemo(() => { - if (!value) { - return new Date(); - } - - return getDateFromString(value); - }, [value]); + const valueAsDate = value ? getDateFromString(value) : null; return ( { - it('Should render now date when value is null', () => { + it('Should render a MM/DD/YYYY placeholder when value is null', () => { const datePickerComponent = renderer.create( @@ -16,11 +16,10 @@ describe('Test DatePickerItem', () => { accessibilityLabel: 'date-picker', }); - const resultProp = format(datePicker.props.value, 'yyyy-MM-dd'); - - const expectedDate = format(new Date(), 'yyyy-MM-dd'); + const placeholder = datePicker.props.placeholder as string; + const expected = 'MM/DD/YYYY'; - expect(resultProp).toBe(expectedDate); + expect(placeholder).toBe(expected); }); it('Should render new Date(0) when value is 1970-01-01', () => {