// @flow
import React from 'react';
import { mountWrappedComponent } from '../../../../utils/tests';
import type { ButtonProps } from './button.proptypes';
import { Button } from './button.component';

const DEFAULT_PROPS = {
  disabled: false,
  size: 'sm',
  children: 'child text',
};

const ACTUAL_BUTTON_PROPS: ButtonProps = {
  ...DEFAULT_PROPS,
  type: 'button',
  onClick: () => {},
};

const LINK_BUTTON_PROPS: ButtonProps = {
  ...DEFAULT_PROPS,
  href: 'https://google.com',
};

describe('Button', () => {
  describe('when passing an onClick', () => {
    it('renders a button element', () => {
      const button = mountWrappedComponent(<Button {...ACTUAL_BUTTON_PROPS} />);
      expect(button.exists('button')).toBe(true);
      expect(button.exists('a')).toBe(false);
    });
  });

  describe('when passed an href', () => {
    it('renders an anchor element', () => {
      const button = mountWrappedComponent(<Button {...LINK_BUTTON_PROPS} />);
      expect(button.exists('button')).toBe(false);
      expect(button.exists('a')).toBe(true);
    });
  });
});
