import React from 'react';
import { shallow } from 'enzyme';
import { Link } from 'react-router-dom';
import { LinkButton as fromLib } from '../../..';
import LinkButton from '../LinkButton';
import Button from '..';
var props = {
  text: 'test text',
  href: 'http://www.google.com'
};
var wrapper;
describe('LinkButton', function () {
  beforeEach(function () {
    wrapper = shallow(React.createElement(LinkButton, props));
  });
  it('should be exported as part of the library', function () {
    expect(fromLib).toEqual(LinkButton);
  });
  it('should render correctly', function () {
    expect(wrapper).toMatchSnapshot();
  });
  describe('external links', function () {
    it('should use an `a` tag', function () {
      var component = wrapper.find(Button).prop('tag');
      expect(component).toBe('a');
    });
    it('should open in a new tab', function () {
      var target = wrapper.find(Button).prop('target');
      expect(target).toBe('_blank');
    });
  });
  describe('internal links', function () {
    it('should use a `Link` tag', function () {
      wrapper.setProps({
        to: '/testPath',
        href: undefined
      });
      var component = wrapper.find(Button).prop('tag');
      expect(component).toBe(Link);
    });
  });
  it('should pass additional props', function () {
    wrapper.setProps({
      id: 'testId',
      type: 'submit',
      variant: 'primary'
    });
    var button = wrapper.find(Button);
    expect(button.prop('id')).toBe('testId');
    expect(button.prop('type')).toBe('submit');
    expect(button.prop('variant')).toBe('primary');
  });
});