<commit_before>import React from 'react';
import chai, { expect } from 'chai';
import chaiEnzyme from 'chai-enzyme';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import { maxBy, minBy } from 'lodash';
import d3Scale from 'd3-scale';
import { line } from 'd3-shape';

import { dataGenerator } from '../../../test-utils';
import { Line } from '../';

chai.use(chaiEnzyme());


describe('<Line />', () => {
  const keyField = 'year_id';
  const valueField = 'value';
  const chartDimensions = {
    width: 600,
    height: 400
  };

  const data = dataGenerator({
    primaryKeys: [{ name: keyField, values: [keyField] }],
    valueKeys: [{ name: valueField, range: [100, 200], uncertainty: true }],
    length: 10
  });

  let component;

  const range = [minBy(data, valueField)[valueField], maxBy(data, valueField)[valueField]];
  const domain = [minBy(data, keyField)[keyField], maxBy(data, keyField)[keyField]];

  const xScale = d3Scale.scalePoint().domain(domain).range([0, chartDimensions.width]);
  const yScale = d3Scale.scaleLinear().domain(range).range([chartDimensions.height, 0]);

  const onClickSpy = sinon.spy((datum) => { return datum; });
  const mouseOverSpy = sinon.spy((datum) => { return datum; });
  const mouseLeaveSpy = sinon.spy((datum) => { return datum; });

  const lineFunction = line()
    .x((datum) => { return xScale(datum[keyField]); })
    .y((datum) => { return yScale(datum[valueField]); });

  const expectedPath = lineFunction(data);

  before(() => {
    component = (
      <Line
        data={data}
        scales={{ x: xScale, y: yScale }}
        dataAccessors={{ x: keyField, y: valueField }}
        clickHandler={onClickSpy}
        onMouseOver={mouseOverSpy}
        onMouseLeave={mouseLeaveSpy}
      />
    );
  });

  afterEach(() => {
    onClickSpy.reset();
    mouseOverSpy.reset();
    mouseLeaveSpy.reset();
  });
<commit_msg>Fix broken Line test.<commit_after>import React from 'react';
import chai, { expect } from 'chai';
import chaiEnzyme from 'chai-enzyme';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import { maxBy, minBy } from 'lodash';
import d3Scale from 'd3-scale';
import { line } from 'd3-shape';

import { dataGenerator } from '../../../test-utils';
import { Line } from '../';

chai.use(chaiEnzyme());


describe('<Line />', () => {
  const keyField = 'year_id';
  const valueField = 'value';
  const chartDimensions = {
    width: 600,
    height: 400
  };

  const data = dataGenerator({
    primaryKeys: [{ name: keyField, values: [keyField] }],
    valueKeys: [{ name: valueField, range: [100, 200], uncertainty: true }],
    length: 10
  });

  let component;

  const range = [minBy(data, valueField)[valueField], maxBy(data, valueField)[valueField]];
  const domain = [minBy(data, keyField)[keyField], maxBy(data, keyField)[keyField]];

  const xScale = d3Scale.scalePoint().domain(domain).range([0, chartDimensions.width]);
  const yScale = d3Scale.scaleLinear().domain(range).range([chartDimensions.height, 0]);

  const onClickSpy = sinon.spy((datum) => { return datum; });
  const mouseOverSpy = sinon.spy((datum) => { return datum; });
  const mouseLeaveSpy = sinon.spy((datum) => { return datum; });

  const lineFunction = line()
    .x((datum) => { return xScale(datum[keyField]); })
    .y((datum) => { return yScale(datum[valueField]); });

  const expectedPath = lineFunction(data);

  before(() => {
    component = (
      <Line
        data={data}
        scales={{ x: xScale, y: yScale }}
        dataAccessors={{ x: keyField, y: valueField }}
        onClick={onClickSpy}
        onMouseOver={mouseOverSpy}
        onMouseLeave={mouseLeaveSpy}
      />
    );
  });

  afterEach(() => {
    onClickSpy.reset();
    mouseOverSpy.reset();
    mouseLeaveSpy.reset();
  });

{'fraction_non_alphanumeric': 0.17197787727153016, 'fraction_numerical': 0.011061364234922308, 'mean_word_length': 3.683107274969174, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 23, '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': '6250607', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1243, 'n_words': 289}