{"size": 1374, "ext": "js", "max_stars_repo_path": "test/inputs/slider_test.js", "max_stars_repo_name": "MadRabbit/a-plus-forms", "max_stars_repo_stars_event_min_datetime": "2017-04-23T11:06:35.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-27T11:17:11.000Z", "max_issues_repo_path": "test/inputs/slider_test.js", "max_issues_repo_name": "MadRabbit/a-plus-forms", "max_issues_repo_issues_event_min_datetime": "2017-11-30T23:12:03.000Z", "max_issues_repo_issues_event_max_datetime": "2021-05-08T07:54:04.000Z", "max_forks_repo_path": "test/inputs/slider_test.js", "max_forks_repo_name": "MadRabbit/a-plus-forms", "max_forks_repo_forks_event_min_datetime": "2017-11-03T00:25:46.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-27T11:17:23.000Z"}
{"max_stars_count": 38, "max_issues_count": 14, "max_forks_count": 8, "avg_line_length": 34.35, "max_line_length": 94, "alphanum_fraction": 0.5720524017}
import React from 'react';
import { spy } from 'sinon';
import { mount } from 'enzyme';
import { Slider } from '../../src';

describe('<Slider />', () => {
  it('renders a slider component', () => {
    const render = mount(<Slider layout={null} value={2} />);
    expect(render.html()).to.eql('<input type="range" min="0" max="10" step="1" value="2">');
  });

  it('allows to specify custom stepping and range', () => {
    const render = mount(<Slider layout={null} min={0} max={2} step={0.2} />);
    expect(render.html()).to.eql('<input type="range" min="0" max="2" step="0.2" value="0">');
  });

  it('understands the `name` prop', () => {
    const render = mount(<Slider layout={null} name="size" />);
    expect(render.html()).to.eql(
      '<input name="size" type="range" min="0" max="10" step="1" value="0">'
    );
  });

  it('understands the `disabled` prop', () => {
    const render = mount(<Slider layout={null} disabled />);
    expect(render.html()).to.eql(
      '<input disabled="" type="range" min="0" max="10" step="1" value="0">'
    );
  });

  it('spits back numbers as the value changes', () => {
    const onChange = spy();
    const render = mount(<Slider onChange={onChange} />);
    render.find('input[type="range"]').simulate('change', {
      target: { value: '12.3' }
    });
    expect(onChange).to.have.been.calledWith(12.3);
  });
});
