<commit_before>jest.dontMock('../src/pill-selector.js');
jest.dontMock('classnames');

describe('PillSelector', function() {
  var React = require('react/addons');
  var PillSelector = require('../src/pill-selector.js');
  var TestUtils = React.addons.TestUtils;

  it('defaults to the first item selected', function() {
    var pills = TestUtils.renderIntoDocument(
      <PillSelector>
        <li>Apricot</li>
        <li>Blueberry</li>
        <li>Cranberry</li>
      </PillSelector>
    );

    var selected = TestUtils.findRenderedDOMComponentWithClass(pills, "ps-selected");
    expect(selected.getDOMNode().textContent).toEqual("Apricot");
  });

  it("changes the text after click and can't be unselected", function() {
    var pills = TestUtils.renderIntoDocument(
      <PillSelector>
        <li>Apricot</li>
        <li ref="click">Blueberry</li>
        <li>Cranberry</li>
      </PillSelector>
    );
    
    var targetNode = pills.refs.click.getDOMNode();
    expect(targetNode.textContent).toEqual("Blueberry");

    TestUtils.Simulate.mouseDown(targetNode);

    var selected = TestUtils.findRenderedDOMComponentWithClass(pills, "ps-selected");
    expect(selected.getDOMNode().textContent).toEqual("Blueberry");

    //reclick and attempt to turn it off
    TestUtils.Simulate.mouseDown(targetNode);

    selected = TestUtils.findRenderedDOMComponentWithClass(pills, "ps-selected");
    expect(selected.getDOMNode().textContent).toEqual("Blueberry");
  });

  it('does change the data after a click', function() {
    var data = null;

    var onClickFunc = function(id, itemData) {
      data = itemData;
    };

    var pills = TestUtils.renderIntoDocument(
      <PillSelector onItemClicked={onClickFunc}>
        <li data="a">Apricot</li>
        <li data="b" ref="click">Blueberry</li>
        <li data="c">Cranberry</li>
      </PillSelector>
    );
    
    expect(data).toBe("a");

    var targetNode = pills.refs.click.getDOMNode();
    TestUtils.Simulate.mouseDown(targetNode);

    expect(data).toBe("b");
  });

  it('does not call click on load when told not to', function() {
    var data = null;

    var onClickFunc = function(id, itemData) {
      data = itemData;
    };

    var pills = TestUtils.renderIntoDocument(
      <PillSelector callClickOnLoad={false} onItemClicked={onClickFunc}>
        <li data="a">Apricot</li>
        <li data="b" ref="click">Blueberry</li>
        <li data="c">Cranberry</li>
      </PillSelector>
    );
    
    expect(data).toBeNull();
  });

  it('can be unselected with differect selection mode', function() {
    var pills = TestUtils.renderIntoDocument(
      <PillSelector selectionMode={PillSelector.ONE_OR_NONE}>
        <li>Apricot</li>
        <li ref="click">Blueberry</li>
        <li>Cranberry</li>
      </PillSelector>
    );
    
    var selected = TestUtils.findRenderedDOMComponentWithClass(pills, "ps-selected");
    expect(selected.getDOMNode().textContent).toEqual("Apricot");

    var targetNode = pills.refs.click.getDOMNode();
    expect(targetNode.textContent).toEqual("Blueberry");

    TestUtils.Simulate.mouseDown(targetNode);

    selected = TestUtils.findRenderedDOMComponentWithClass(pills, "ps-selected");
    expect(selected.getDOMNode().textContent).toEqual("Blueberry");

    //reclick and attempt to turn it off
    TestUtils.Simulate.mouseDown(targetNode);<commit_msg>fixed tests<commit_after>jest.dontMock('../src/pill-selector.js');
jest.dontMock('classnames');

describe('PillSelector', function() {
  var React = require('react/addons');
  var PillSelector = require('../src/pill-selector.js');
  var TestUtils = React.addons.TestUtils;

  it('defaults to the first item selected', function() {
    var pills = TestUtils.renderIntoDocument(
      <PillSelector>
        <li>Apricot</li>
        <li>Blueberry</li>
        <li>Cranberry</li>
      </PillSelector>
    );

    var selected = TestUtils.findRenderedDOMComponentWithClass(pills, "ps-selected");
    expect(selected.getDOMNode().textContent).toEqual("Apricot");
  });

  it("changes the text after click and can't be unselected", function() {
    var pills = TestUtils.renderIntoDocument(
      <PillSelector>
        <li>Apricot</li>
        <li ref="click">Blueberry</li>
        <li>Cranberry</li>
      </PillSelector>
    );
    
    var targetNode = pills.refs.click.getDOMNode();
    expect(targetNode.textContent).toEqual("Blueberry");

    TestUtils.Simulate.click(targetNode);

    var selected = TestUtils.findRenderedDOMComponentWithClass(pills, "ps-selected");
    expect(selected.getDOMNode().textContent).toEqual("Blueberry");

    //reclick and attempt to turn it off
    TestUtils.Simulate.click(targetNode);

    selected = TestUtils.findRenderedDOMComponentWithClass(pills, "ps-selected");
    expect(selected.getDOMNode().textContent).toEqual("Blueberry");
  });

  it('does change the data after a click', function() {
    var data = null;

    var onClickFunc = function(id, itemData) {
      data = itemData;
    };

    var pills = TestUtils.renderIntoDocument(
      <PillSelector onItemClicked={onClickFunc}>
        <li data="a">Apricot</li>
        <li data="b" ref="click">Blueberry</li>
        <li data="c">Cranberry</li>
      </PillSelector>
    );
    
    expect(data).toBe("a");

    var targetNode = pills.refs.click.getDOMNode();
    TestUtils.Simulate.click(targetNode);

    expect(data).toBe("b");
  });

  it('does not call click on load when told not to', function() {
    var data = null;

    var onClickFunc = function(id, itemData) {
      data = itemData;
    };

    var pills = TestUtils.renderIntoDocument(
      <PillSelector callClickOnLoad={false} onItemClicked={onClickFunc}>
        <li data="a">Apricot</li>
        <li data="b" ref="click">Blueberry</li>
        <li data="c">Cranberry</li>
      </PillSelector>
    );
    
    expect(data).toBeNull();
  });

  it('can be unselected with differect selection mode', function() {
    var pills = TestUtils.renderIntoDocument(
      <PillSelector selectionMode={PillSelector.ONE_OR_NONE}>
        <li>Apricot</li>
        <li ref="click">Blueberry</li>
        <li>Cranberry</li>
      </PillSelector>
    );
    
    var selected = TestUtils.findRenderedDOMComponentWithClass(pills, "ps-selected");
    expect(selected.getDOMNode().textContent).toEqual("Apricot");

    var targetNode = pills.refs.click.getDOMNode();
    expect(targetNode.textContent).toEqual("Blueberry");

    TestUtils.Simulate.click(targetNode);

    selected = TestUtils.findRenderedDOMComponentWithClass(pills, "ps-selected");
    expect(selected.getDOMNode().textContent).toEqual("Blueberry");

    //reclick and attempt to turn it off
    TestUtils.Simulate.click(targetNode);
{'fraction_non_alphanumeric': 0.14370546318289787, 'fraction_numerical': 0.0, 'mean_word_length': 3.521476510067114, 'pattern_counts': {'":': 0, '<': 83, '<?xml version=': 0, '>': 83, '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': '6252353', 'n_tokens_mistral': 2125, 'n_tokens_neox': 2080, 'n_words': 370}