import { render, mockMatchMedia } from '../test-utils';

import DateLookup from '.';

mockMatchMedia();

// This test suite could become redundant
// once we refactor the DateLookup component to TypeScript

describe('DateLookup propTypes', () => {
  describe('when the value prop is set to null', () => {
    it('renders without prop type warnings in the console', () => {
      const consoleSpy = jest.spyOn(console, 'error').mockImplementation(() => {});

      render(<DateLookup value={null} onChange={jest.fn()} />);

      // eslint-disable-next-line no-console
      expect(console.error).not.toHaveBeenCalledWith(
        expect.stringContaining('Warning: Failed %s type'),
        'prop',
        'The prop `value` is marked as required in `DateLookup`, but its value is `null`.',
        expect.anything(),
      );

      consoleSpy.mockRestore();
    });
  });
});
