// @flow
import React from 'react';
import { renderSnapshot } from '../../../../utils/tests';

import type {
  MaskedTextInputProps,
  MaskedTextInputOptions,
} from './masked-text-input.proptypes';
import { MaskedTextInput } from './index';

const DEFAULT_OPTIONS: MaskedTextInputOptions = {
  date: true,
  datePattern: ['d', 'm', 'Y'],
};

const DEFAULT_PROPS: MaskedTextInputProps<string> = {
  id: 'a-great-id',
  type: 'text',
  placeholder: 'DD / MM / YYYY',
  value: '12/04/1980',
  disabled: false,
  error: false,
  focusOnMount: false,
  large: false,
  iconType: 'lock',
  iconPosition: 'left',
  onChange: jest.fn(),
  onFocus: jest.fn(),
  onBlur: jest.fn(),
  options: DEFAULT_OPTIONS,
};

describe('MaskedTextInput', () => {
  describe('snapshot', () => {
    it('matches the previous snapshot', () => {
      const maskedTextInputRendered = renderSnapshot(
        <MaskedTextInput {...DEFAULT_PROPS} />,
      );
      expect(maskedTextInputRendered).toMatchSnapshot();
    });
  });
});
