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

import type { SelectorItemWithInputProps } from './selector-item.proptypes';
import { SelectorItemWithInput as Item } from './index';
import { Selector } from '..';

const DEFAULT_PROPS: SelectorItemWithInputProps = {
  children: <span>Child</span>,
  id: 'selector-id',
  value: 'vanilla',
  name: 'ice-cream',
  type: 'text',
  label: 'a good label',
  secondaryLabel: 'another good label',
  checked: false,
  disabled: false,
  large: false,
  inputValue: 'abc',
  onInputChange: () => {},
};

const noop = () => {};

describe('SelectorItemWithInput', () => {
  describe('snapshot', () => {
    it('matches the previous snapshot', () => {
      const handleOnChange = jest.fn();
      const selectorItem = mountWrappedComponent(
        <Selector name="test" size="lg" onChange={noop}>
          <Item {...DEFAULT_PROPS} onChange={handleOnChange} />,
        </Selector>,
      );
      expect(selectorItem).toMatchSnapshot();
    });
  });
});
