{"size": 1811, "ext": "js", "max_stars_repo_path": "tests/index-test.js", "max_stars_repo_name": "A1ex5andr/react-options", "max_stars_repo_stars_event_min_datetime": "2017-12-26T19:01:26.000Z", "max_stars_repo_stars_event_max_datetime": "2017-12-26T19:01:26.000Z", "max_issues_repo_path": "tests/index-test.js", "max_issues_repo_name": "AlexCoderBit/react-options", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "tests/index-test.js", "max_forks_repo_name": "AlexCoderBit/react-options", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 1, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 24.1466666667, "max_line_length": 67, "alphanum_fraction": 0.6250690226}
import expect from 'expect';
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import React from 'react';
import { render, unmountComponentAtNode } from 'react-dom';
import ReactOptions from '../src/';

Enzyme.configure({ adapter: new Adapter() });

const Details = (
  <div>
    <h3>Details</h3>
  </div>
);

const Children = (
  <div>
    <p>Children Data</p>
  </div>
);

const Component = (
  <ReactOptions key="1" id="1" optionsActive="0" details={Details}>
    {Children}
  </ReactOptions>
);

describe('ReactOptions component', () => {
  let node;

  beforeEach(() => {
    node = document.createElement('div');
  });

  afterEach(() => {
    unmountComponentAtNode(node);
  });

  it('renders children content', () => {
    const component = Enzyme.shallow(Component);
    expect(component.contains(Children)).toBeTruthy();
  });

  it('renders options content', () => {
    render(Component, node, () => {
      expect(node.innerHTML).toContain('Details');
    });
  });

  it('renders wrapper class for content', () => {
    render(Component, node, () => {
      expect(node.innerHTML).toContain('ro-wrapper');
    });
  });

  it('renders main class for content', () => {
    render(Component, node, () => {
      expect(node.innerHTML).toContain('ro-main');
    });
  });

  it('activates details class for options', () => {
    const component = Enzyme.shallow(Component);
    component.setProps({ optionsActive: '1' });
    expect(component.find('.ro-details_show').length).toBeTruthy();
  });

  it('deactivates details class for options', () => {
    const component = Enzyme.shallow(Component);
    component.setProps({ optionsActive: '1' });
    component.setProps({ optionsActive: '2' });
    expect(component.find('.ro-details_show').length).toBeFalsy();
  });
});
