<commit_before>/* global afterEach, beforeEach, describe, it, document */
import chai, { expect } from 'chai';
import React from 'react';
import ReactDOM from 'react-dom';
import sinon from 'sinon';
import sinonChai from 'sinon-chai';

import createComponent from '../createComponent';
import h from '../h';

const sandbox = sinon.sandbox.create();
chai.use(sinonChai);

describe('react › createComponent', function () {
  it('is a function', function () {
    expect(createComponent).to.be.a('function');
  });

  it('throws error if render method is not given', function () {
    expect(() => {
      createComponent();
    }).to.throw(/missing required method: render/);
  });

  it('returns Component that can be rendered to DOM', function () {
    const MyComponent = createComponent({
      render() {
        return (
          <p id="paragraph">Hello World</p>
        );
      }
    });

    const instance = ReactDOM.render(
      <MyComponent />,
      document.getElementById('root')
    );

    const element = document.getElementById('paragraph');
    expect(element.innerHTML).to.equal('Hello World');
  });

  it('gets the DOM Node when executing getDOMElement()', function () {
    const MyComponent = createComponent({
      render() {
        return (
          <p id="paragraph">Hello World</p>
        );
      }
    });

    const instance = ReactDOM.render(
      <MyComponent />,
      document.getElementById('root')
    );

    expect(instance.getDOMElement()).to.be.equal(document.querySelector('#paragraph'));
  });

  it('fires mount callbacks', function () {
    let beforeMountCalled = false;
    let afterMountCalled = false;
    let beforeUnmountCalled = false;

    const MyComponent = createComponent({
      beforeMount() {
        beforeMountCalled = true;
      },
      afterMount() {
        afterMountCalled = true;
      },
      beforeUnmount() {
        beforeUnmountCalled = true;
      },
      render() {
        return (
          <p>Hello World</p>
        );
      }
    });

    const node = document.getElementById('root')
    const instance = ReactDOM.render(
      <MyComponent />,
      node
    );

    expect(beforeMountCalled).to.equal(true);
    expect(afterMountCalled).to.equal(true);

    React.unmountComponentAtNode(node);
    expect(beforeUnmountCalled).to.equal(true);
  });
});<commit_msg>tests: eslint fixes in `createComponent` spec.<commit_after>/* global afterEach, beforeEach, describe, it, document */
import { expect } from 'chai';
import ReactDOM from 'react-dom';

import createComponent from '../createComponent';
import h from '../h';

describe('react › createComponent', function () {
  it('is a function', function () {
    expect(createComponent).to.be.a('function');
  });

  it('throws error if render method is not given', function () {
    expect(() => {
      createComponent();
    }).to.throw(/missing required method: render/);
  });

  it('returns Component that can be rendered to DOM', function () {
    const MyComponent = createComponent({
      render() {
        return (
          <p id="paragraph">Hello World</p>
        );
      }
    });

    ReactDOM.render(
      <MyComponent />,
      document.getElementById('root')
    );

    const element = document.getElementById('paragraph');
    expect(element.innerHTML).to.equal('Hello World');
  });

  it('gets the DOM Node when executing getDOMElement()', function () {
    const MyComponent = createComponent({
      render() {
        return (
          <p id="paragraph">Hello World</p>
        );
      }
    });

    const instance = ReactDOM.render(
      <MyComponent />,
      document.getElementById('root')
    );

    expect(instance.getDOMElement()).to.be.equal(document.querySelector('#paragraph'));
  });

  it('fires mount callbacks', function () {
    let beforeMountCalled = false;
    let afterMountCalled = false;
    let beforeUnmountCalled = false;

    const MyComponent = createComponent({
      beforeMount() {
        beforeMountCalled = true;
      },
      afterMount() {
        afterMountCalled = true;
      },
      beforeUnmount() {
        beforeUnmountCalled = true;
      },
      render() {
        return (
          <p>Hello World</p>
        );
      }
    });

    const node = document.getElementById('root');
    ReactDOM.render(
      <MyComponent />,
      node
    );

    expect(beforeMountCalled).to.equal(true);
    expect(afterMountCalled).to.equal(true);

    ReactDOM.unmountComponentAtNode(node);
    expect(beforeUnmountCalled).to.equal(true);
  });
});
{'fraction_non_alphanumeric': 0.1426377002413869, 'fraction_numerical': 0.0, 'mean_word_length': 2.736065573770492, 'pattern_counts': {'":': 0, '<': 21, '<?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': '396600', 'n_tokens_mistral': 1286, 'n_tokens_neox': 1273, 'n_words': 292}