import React from 'react';
import { render } from '@testing-library/react';
import FormTestBase from '../../__Tests__/FormTestBase';
import {
  MultiStringSelectGroup,
  SingleStringSelectGroup,
} from '../StringSelectGroup';

describe('SingleStringSelectGroup', () => {
  it('renders without crashing', () => {
    render(
      <FormTestBase>
        {({ Field }) => (
          <Field
            name="favoriteColor"
            Component={SingleStringSelectGroup}
            label="Favorite Color"
            options={[
              { label: 'Blue', value: 'Blue' },
              { label: 'Green', value: 'Green' },
              { label: 'Red', value: 'Red' },
            ]}
          />
        )}
      </FormTestBase>
    );
  });

  it('has matching snapshot', () => {
    const renderResult = render(
      <FormTestBase>
        {({ Field }) => (
          <Field
            name="favoriteColor"
            Component={SingleStringSelectGroup}
            label="Favorite Color"
            options={[
              { label: 'Blue', value: 'Blue' },
              { label: 'Green', value: 'Green' },
              { label: 'Red', value: 'Red' },
            ]}
          />
        )}
      </FormTestBase>
    );
    expect(renderResult.asFragment()).toMatchSnapshot();
  });
});

describe('MultiStringSelectGroup', () => {
  it('renders without crashing', () => {
    render(
      <FormTestBase>
        {({ Field }) => (
          <Field
            name="favoriteColors"
            Component={MultiStringSelectGroup}
            label="Favorite Color"
            options={[
              { label: 'Blue', value: 'Blue' },
              { label: 'Green', value: 'Green' },
              { label: 'Red', value: 'Red' },
            ]}
          />
        )}
      </FormTestBase>
    );
  });

  it('has matching snapshot', () => {
    const renderResult = render(
      <FormTestBase>
        {({ Field }) => (
          <Field
            name="favoriteColors"
            Component={MultiStringSelectGroup}
            label="Favorite Color"
            options={[
              { label: 'Blue', value: 'Blue' },
              { label: 'Green', value: 'Green' },
              { label: 'Red', value: 'Red' },
            ]}
          />
        )}
      </FormTestBase>
    );
    expect(renderResult.asFragment()).toMatchSnapshot();
  });
});
