message: Add tests for keyboard input validation
diff: +import addDays from 'date-fns/addDays';
  import { ReactWrapper } from 'enzyme';
  import * as React from 'react';
  import KeyboardDatePicker, { KeyboardDatePickerProps } from '../../DatePicker/KeyboardDatePicker';
  @@ -21,14 +22,6 @@ describe('e2e -- DatePicker keyboard input', () => {
  InputLabelProps={{
  htmlFor: 'your-id',
  }}
  - // TODO support
  - // InputProps={{
  - // endAdornment: (
  - // <InputAdornment position="end">
  - // <IconButton>date_range</IconButton>
  - // </InputAdornment>
  - // ),
  - // }}
  />
  );
  });
  @@ -43,3 +36,47 @@ describe('e2e -- DatePicker keyboard input', () => {
  expect(onChangeMock).toBeCalled();
  });
  });
  +
  +describe('e2e -- KeyboardDatePicker validation errors', () => {
  + it('Should render error message if date is unparseable', () => {
  + const component = mount(
  + <KeyboardDatePicker
  + format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
  + value={new Date(NaN)}
  + onChange={jest.fn()}
  + />
  + );
  +
  + expect(component.find('TextField').prop('helperText')).toBe('Invalid Date Format');
  + });
  +
  + it('Should render error message if date is after maxDate', () => {
  + const component = mount(
  + <KeyboardDatePicker
  + onChange={jest.fn()}
  + disableFuture
  + value={addDays(new Date(), 2)}
  + format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
  + />
  + );
  +
  + expect(component.find('TextField').prop('helperText')).toBe(
  + 'Date should not be after maximal date'
  + );
  + });
  +
  + it('Should render error message if date is after maxDate', () => {
  + const component = mount(
  + <KeyboardDatePicker
  + onChange={jest.fn()}
  + disablePast
  + value={addDays(new Date(), -2)}
  + format={process.env.UTILS === 'moment' ? 'DD/MM/YYYY' : 'dd/MM/yyyy'}
  + />
  + );
  +
  + expect(component.find('TextField').prop('helperText')).toBe(
  + 'Date should not be before minimal date'
  + );
  + });
  +});
  