{"size": 1286, "ext": "js", "max_stars_repo_path": "src/lib/components/PageGrid/molecules/Typography/components/Link/Link.test.js", "max_stars_repo_name": "apjames93/mui-storyblok", "max_stars_repo_stars_event_min_datetime": "2020-03-24T03:43:43.000Z", "max_stars_repo_stars_event_max_datetime": "2020-09-03T13:59:10.000Z", "max_issues_repo_path": "src/lib/components/PageGrid/molecules/Typography/components/Link/Link.test.js", "max_issues_repo_name": "mui-storyblok/mui-storyblok", "max_issues_repo_issues_event_min_datetime": "2020-11-18T01:46:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-01-08T21:02:13.000Z", "max_forks_repo_path": "src/lib/components/PageGrid/molecules/Typography/components/Link/Link.test.js", "max_forks_repo_name": "apjames93/mui-storyblok", "max_forks_repo_forks_event_min_datetime": "2020-04-12T16:00:53.000Z", "max_forks_repo_forks_event_max_datetime": "2020-09-26T23:46:43.000Z"}
{"max_stars_count": 11, "max_issues_count": 11, "max_forks_count": 5, "avg_line_length": 27.3617021277, "max_line_length": 76, "alphanum_fraction": 0.6057542768}
import React from 'react';
import { mount } from 'enzyme';
import renderer from 'react-test-renderer';
import { Link } from './Link';

function setup(external = true) {
  const props = {
    text: 'wooo',
    href: '/page-cool',
    external,
  };
  const comp = mount(<Link {...props} />);

  return { comp, props };
}

describe('<Link />', () => {
  it('renders Link', () => {
    const { comp } = setup();
    expect(comp).toBeDefined();
  });

  it('handleClick and call external false ', () => {
    const { assign } = window.location;
    window.location.assign = jest.fn();
    const { comp } = setup(false);
    comp.find('WithStyles(ForwardRef(Typography))').at(0).simulate('click');
    expect(window.location.assign).toBeCalled();
    window.location.assign = assign;
  });

  it.skip('handleClick and call external true ', () => {
    const { assign } = window.location;
    window.location.assign = jest.fn();
    const { comp } = setup(true);
    comp.find('WithStyles(ForwardRef(Typography))').at(0).simulate('click');
    expect(window.location.assign).toBeCalled();
    window.location.assign = assign;
  });

  test('snapshot', () => {
    const { props } = setup();
    const tree = renderer.create(<Link {...props} />);
    expect(tree).toMatchSnapshot();
  });
});
