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