<commit_before>// @flow weak
/* eslint-env mocha */

import React from 'react';
import { assert } from 'chai';
import { shallow } from 'enzyme';
import TickGroup from './TickGroup';

const noop = () => {};

describe('<TickGroup />', () => {
  it('should render an g element', () => {
    const wrapper = shallow(
      <TickGroup scale={noop} tickComponent={noop} />,
    );
    assert.strictEqual(wrapper.is('g'), true, 'should be a g element');
  });

  // it('should spread props to tick components', () => {
  //   const wrapper = shallow(
  //     <TickGroup data-test="hello" />,
  //   );
  //   assert.strictEqual(wrapper.prop('data-test'), 'hello', 'should be spread on TickGroup');
  // });

  it('should add user classes', () => {
    const wrapper = shallow(<TickGroup scale={noop} tickComponent={noop} className="wu-tang" />);
    assert.strictEqual(wrapper.hasClass('wu-tang'), true, 'should have the wu-tang class');
  });
});

<commit_msg>add more tests for TickGroup<commit_after>// @flow weak
/* eslint-env mocha */

import React from 'react';
import sinon from 'sinon';
import { assert } from 'chai';
import { shallow, mount } from 'enzyme';
import TickGroup from './TickGroup';

const Tick = () => <line />;
const scale = () => {};
scale.ticks = () => [1, 2, 3, 4, 5];

describe('<TickGroup />', () => {
  it('should render a g element', () => {
    const wrapper = shallow(
      <TickGroup scale={scale} tickComponent={Tick} />,
    );
    assert.strictEqual(wrapper.is('g'), true, 'should be a g element');
  });

  it('should render a tick for each tick in the scale', () => {
    const wrapper = mount(
      <TickGroup scale={scale} tickComponent={Tick} />,
    );

    assert.strictEqual(wrapper.find(Tick).length, scale.ticks().length, 'should be equal');
  });

  it('should add udid to removed map when calling removeTick', () => {
    const wrapper = mount(
      <TickGroup scale={scale} tickComponent={Tick} />,
    );

    const instance = wrapper.instance();

    instance.removeTick('key-1');
    assert.strictEqual(instance.removed.has('key-1'), true, 'key should exist in map');
  });

  it('should pass props to Tick components', () => {
    const wrapper = mount(
      <TickGroup test-prop="wu-tang" scale={scale} tickComponent={Tick} />,
    );

    const ticks = wrapper.find(Tick);

    let count = 0;

    ticks.forEach((n) => {
      if (n.prop('test-prop') === 'wu-tang') count++;
    });

    assert.strictEqual(count, scale.ticks().length, 'each Tick should have the test-prop');
  });

  it('should call updateTicks when given new scale prop', () => {
    const wrapper = mount(
      <TickGroup scale={scale} tickComponent={Tick} />,
    );

    const nextScale = () => {};
    nextScale.ticks = () => [1, 2, 3, 4, 5];

    sinon.spy(TickGroup.prototype, 'updateTicks');

    wrapper.setProps({ scale: nextScale });

    const calledOnce = TickGroup.prototype.updateTicks.calledOnce;

    assert.strictEqual(calledOnce, true, 'should have been called once');
  });

  it('should add user classes', () => {
    const wrapper = shallow(<TickGroup scale={scale} tickComponent={Tick} className="wu-tang" />);
    assert.strictEqual(wrapper.hasClass('wu-tang'), true, 'should have the wu-tang class');
  });
});

{'fraction_non_alphanumeric': 0.18293431553100062, 'fraction_numerical': 0.003990178023327195, 'mean_word_length': 3.446111869031378, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 33, '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': '5877169', 'n_tokens_mistral': 1050, 'n_tokens_neox': 1005, 'n_words': 270}