<commit_before>import React from 'react';
import Enzyme, { shallow, mount, render } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { StaticGoogleMap, Marker, Path, Direction } from '../src/index';

Enzyme.configure({ adapter: new Adapter() });

describe('Components', () => {
  test('It exports Components', () => {
    expect(StaticGoogleMap).toBeDefined();
    expect(Marker).toBeDefined();
    expect(Path).toBeDefined();
    expect(Direction).toBeDefined();
  });

  test('Marker and Path component have Group property', () => {
    expect(Marker.Group).toBeDefined();
    expect(Path.Group).toBeDefined();
  });

  test('It throws if size property is not set', () => {
    console.error = jest.fn();
    expect(() => mount(<StaticGoogleMap />)).toThrowError();
    expect(console.error).toHaveBeenCalled();
  });

  test('It throws if no child is present', () => {
    console.error = jest.fn();
    expect(() => mount(<StaticGoogleMap size="200x200" />)).toThrow();
    expect(console.error).toHaveBeenCalled();
  });

  test('It renders an image with default props', done => {
    const wrapper = mount(
      <StaticGoogleMap size="test">
        <Marker location="location" />
      </StaticGoogleMap>
    );

    setTimeout(() => {
      wrapper.update();
      const node = wrapper.getDOMNode();
      expect(node.localName).toBe('img');
      expect(node).toMatchSnapshot();
      done();
    });
  });

  test('It renders composite child elements', done => {
    const RedMarker = ({ color, ...props }) => (
      <Marker color="red" {...props} />
    );

    const wrapper = mount(
      <StaticGoogleMap size="test">
        <RedMarker location="test" />
      </StaticGoogleMap>
    );

    setTimeout(() => {
      wrapper.update();
      const node = wrapper.getDOMNode();
      expect(node.getAttribute('src').includes('marker')).toBe(true);
      expect(node.getAttribute('src')).toContain('color=red');
      done();
    }, 15);
  });

  test('It calls onGenerate method when a URL is successfully generated', done => {
    const onGenerate = jest.fn();
    const wrapper = mount(
      <StaticGoogleMap size="test" onGenerate={onGenerate}>
        <Marker location="test" />
        <Path points="test" />
      </StaticGoogleMap>
    );

    setTimeout(() => {
      wrapper.update();
      const node = wrapper.getDOMNode();<commit_msg>Fix failing test<commit_after>import React from 'react';
import Enzyme, { shallow, mount, render } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import { StaticGoogleMap, Marker, Path, Direction } from '../src/index';

Enzyme.configure({ adapter: new Adapter() });

describe('Components', () => {
  test('It exports Components', () => {
    expect(StaticGoogleMap).toBeDefined();
    expect(Marker).toBeDefined();
    expect(Path).toBeDefined();
    expect(Direction).toBeDefined();
  });

  test('Marker and Path component have Group property', () => {
    expect(Marker.Group).toBeDefined();
    expect(Path.Group).toBeDefined();
  });

  test('It throws if size property is not set', () => {
    console.error = jest.fn();
    expect(() => mount(<StaticGoogleMap />)).toThrowError();
    expect(console.error).toHaveBeenCalled();
  });

  test('It throws if no child is present', () => {
    console.error = jest.fn();
    expect(() => mount(<StaticGoogleMap size="200x200" />)).toThrow();
    expect(console.error).toHaveBeenCalled();
  });

  test('It renders an image with default props', done => {
    const wrapper = mount(
      <StaticGoogleMap size="test">
        <Marker location="location" />
      </StaticGoogleMap>
    );

    setTimeout(() => {
      wrapper.update();
      const node = wrapper.getDOMNode();
      expect(node.localName).toBe('img');
      expect(node).toMatchSnapshot();
      done();
    });
  });

  test('It renders composite child elements', done => {
    const RedMarker = ({ color, ...props }) => (
      <Marker color="red" {...props} />
    );

    const wrapper = mount(
      <StaticGoogleMap size="test">
        <RedMarker location="test" />
      </StaticGoogleMap>
    );

    setTimeout(() => {
      wrapper.update();
      const node = wrapper.getDOMNode();
      expect(node.getAttribute('src').includes('marker')).toBe(true);
      expect(node.getAttribute('src')).toContain('color:red');
      done();
    }, 15);
  });

  test('It calls onGenerate method when a URL is successfully generated', done => {
    const onGenerate = jest.fn();
    const wrapper = mount(
      <StaticGoogleMap size="test" onGenerate={onGenerate}>
        <Marker location="test" />
        <Path points="test" />
      </StaticGoogleMap>
    );

    setTimeout(() => {
      wrapper.update();
      const node = wrapper.getDOMNode();
{'fraction_non_alphanumeric': 0.17537235158380532, 'fraction_numerical': 0.004195510803440319, 'mean_word_length': 3.215738284703802, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 57, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4074094', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1356, 'n_words': 311}