<commit_before>import React from "react";
import { mount, shallow } from "enzyme";
import { expect } from "chai";
import { AutocompleteCore } from "../../index";

let count = 0;
let inputProps = {
  "placeholder": "Type 'c'",
  "value": "value",
  "onChange": function() {
    count++;
  }
};

let badValueProps = {};

let badOnChangeProps = {
  "value": "value"
};

describe("Test Autocomplete component", () => {
  it("Test default props", function() {
    const result = mount(<AutocompleteCore inputProps={inputProps} />);
    expect(typeof result.props().onSuggestionsUpdateRequested).to.equal(
      "function"
    );
    expect(typeof result.props().shouldRenderSuggestions).to.equal("function");
    expect(typeof result.props().onSuggestionSelected).to.equal("function");
    expect(typeof result.props().renderSectionTitle).to.equal("function");
    expect(typeof result.props().getSectionSuggestions).to.equal("function");
    expect(result.props().focusInputOnSuggestionClick).to.equal(true);
    expect(result.props().id).to.equal("1");

    expect(result.props().renderSectionTitle()).to.throw(Error);
    expect(result.props().getSectionSuggestions()).to.throw(new Error(
      "`getSectionSuggestions` must be provided"
    ));
  });

  it("Check inputProps", function() {
    const result = mount(<AutocompleteCore inputProps={inputProps} />);
    expect(result.props().inputProps).to.equal(inputProps);
  });

  it("Make sure onChange function can be called", function() {
    const result = shallow(<AutocompleteCore inputProps={inputProps} />);
    result.simulate("change", { "target": { "value": "1234567890!!!" } });
    expect(count).to.equal(1);
  });

  it("Make sure error is thrown when no value is set.", function() {
    // const result = mount(<Autocomplete inputProps={badValueProps}></Autocomplete>)
    // expect(result.).to.throw(Error);
  });

  it("Make sure error is thrown when no onChange is set.", function() {
    // expect(mount(<Autocomplete inputProps={badOnChangeProps}></Autocomplete>)).toThrow(new Error('\'inputProps\' must have \'onChange\'.'));
  });
});
<commit_msg>cleanup eslint errors in autocomplete test.<commit_after>import React from "react";
import { mount, shallow } from "enzyme";
import { expect } from "chai";
import { AutocompleteCore } from "../../index";

let count = 0;
let inputProps = {
  "placeholder": "Type 'c'",
  "value": "value",
  "onChange": function() {
    count++;
  }
};

describe("Test Autocomplete component", () => {
  it("Test default props", function() {
    const result = mount(<AutocompleteCore inputProps={inputProps} />);
    expect(typeof result.props().onSuggestionsUpdateRequested).to.equal(
      "function"
    );
    expect(typeof result.props().shouldRenderSuggestions).to.equal("function");
    expect(typeof result.props().onSuggestionSelected).to.equal("function");
    expect(typeof result.props().renderSectionTitle).to.equal("function");
    expect(typeof result.props().getSectionSuggestions).to.equal("function");
    expect(result.props().focusInputOnSuggestionClick).to.equal(true);
    expect(result.props().id).to.equal("1");

    expect(result.props().renderSectionTitle()).to.throw(Error);
    expect(result.props().getSectionSuggestions()).to.throw(new Error(
      "`getSectionSuggestions` must be provided"
    ));
  });

  it("Check inputProps", function() {
    const result = mount(<AutocompleteCore inputProps={inputProps} />);
    expect(result.props().inputProps).to.equal(inputProps);
  });

  it("Make sure onChange function can be called", function() {
    const result = shallow(<AutocompleteCore inputProps={inputProps} />);
    result.simulate("change", { "target": { "value": "1234567890!!!" } });
    expect(count).to.equal(1);
  });
});

{'fraction_non_alphanumeric': 0.17834394904458598, 'fraction_numerical': 0.006900212314225053, 'mean_word_length': 4.6591591591591595, 'pattern_counts': {'":': 11, '<': 13, '<?xml version=': 0, '>': 15, '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': '5565253', 'n_tokens_mistral': 1143, 'n_tokens_neox': 1081, 'n_words': 216}