import React from 'react';
import { render } from '@testing-library/react';
import StringDatePickerGroup from './StringDatePickerGroup';
import FormTestBase from '../__Tests__/FormTestBase';

//hack so the datepicker internals don't complain about this not existing in the context of jest
HTMLCanvasElement.prototype.getContext = () => null;

describe('IconInputGroup', () => {
  it('renders without crashing', () => {
    render(
      <FormTestBase>
        {({ Field }) => (
          <Field
            name="favoriteDate"
            Component={StringDatePickerGroup}
            label="Favorite Date"
            monthPlaceholder="mm"
            dayPlaceholder="dd"
            yearPlaceholder="yyyy"
            maxDate={new Date('9/23/2023')}
            minDate={new Date('6/22/2022')}
          />
        )}
      </FormTestBase>
    );
  });

  it('has matching snapshot', () => {
    const renderResult = render(
      <FormTestBase>
        {({ Field }) => (
          <Field
            name="favoriteDate"
            Component={StringDatePickerGroup}
            label="Favorite Date"
            monthPlaceholder="mm"
            dayPlaceholder="dd"
            yearPlaceholder="yyyy"
            maxDate={new Date('9/23/2023')}
            minDate={new Date('6/22/2022')}
          />
        )}
      </FormTestBase>
    );
    expect(renderResult.asFragment()).toMatchSnapshot();
  });
});
