<commit_before>// jest.dontMock('../src/range-finder.js');
// jest.dontMock('../src/mixins/calculatedPropertyMixin.js');
// jest.dontMock('../src/mixins/componentMakerMixin.js');
// jest.dontMock('../src/mixins/rangeFinderSetupMixin.js');
// jest.dontMock('../src/components/coverageBar.js');
// jest.dontMock('../src/components/scrollableSVG.js');
// jest.dontMock('../src/components/slider.js');
// jest.dontMock('interact.js');

jest.autoMockOff();

var data = [];

var start = 1;
var mid = 6;
var end = 10;

var series = "series";
var value = "value";
var colors = ["red","darkred","limegreen","darkgreen","dodgerblue","darkblue"];

function makeRange(label, start, end) {
  var arr = [];

  for(var i = start; i <= end; i++) {
    var dataObj = {};
    dataObj[series] = label;
    dataObj[value] = i;

    arr.push(dataObj);
  }

  return arr;
}

data = data.concat(makeRange("r1", start, end));
data = data.concat(makeRange("r2", mid, end));

var React = require('react/addons');
var RangeFinder = require('../src/range-finder.js');

var controler = function(){};

var RangeFinderRenderer = React.createClass({
  getInitialState: function() {
    return this.props;
  },

  componentDidMount: function() {
    controler = this.controlState;
  },

  controlState: function(newState) {
    this.setState(newState);
  },

  render: function() {
    return <RangeFinder {...this.state}/>
  }
});

describe('Range Finder', function() {
  var TestUtils = React.addons.TestUtils;

  var scryClass = TestUtils.scryRenderedDOMComponentsWithClass;
  var findClass = TestUtils.findRenderedDOMComponentWithClass;

  it('Shows value indicators', function() {
    var rangeFinder = TestUtils.renderIntoDocument(
      <RangeFinderRenderer 
        id="yearSelector"
        data={data}
        rowLabelProperties={series}
        valueProperty={value}
        colors={colors}/>
    );

    var newStart = start + 1;
    var newEnd = end - 1;

    var indicators = scryClass(rangeFinder, 'rf-value-indeicators');
    expect(indicators.length).toBe(0);

    var newRange = {start: newStart};
    controler({selectedRange: newRange});
    indicators = scryClass(rangeFinder, 'rf-value-indeicators');
    expect(indicators.length).toBe(1);

    newRange = {start: newStart, end: newEnd};
    controler({selectedRange: newRange});
    indicators = scryClass(rangeFinder, 'rf-value-indeicators');
    expect(indicators.length).toBe(2);

    newRange = {end: newEnd};
    controler({selectedRange: newRange});
    indicators = scryClass(rangeFinder, 'rf-value-indeicators');
    expect(indicators.length).toBe(1);

    newRange = {};
    controler({selectedRange: newRange});
    indicators = scryClass(rangeFinder, 'rf-value-indeicators');
    expect(indicators.length).toBe(0);
  });

  it('Shows proper data density', function() {
    console.log(data)
    var rangeFinder = TestUtils.renderIntoDocument(
      <RangeFinderRenderer 
        id="yearSelector"
        data={data}
        rowLabelProperties={series}
        valueProperty={value}
        colors={colors}/>
    );

    var density = findClass(rangeFinder, 'rf-density-label').props.children;<commit_msg>removed extra log message<commit_after>// jest.dontMock('../src/range-finder.js');
// jest.dontMock('../src/mixins/calculatedPropertyMixin.js');
// jest.dontMock('../src/mixins/componentMakerMixin.js');
// jest.dontMock('../src/mixins/rangeFinderSetupMixin.js');
// jest.dontMock('../src/components/coverageBar.js');
// jest.dontMock('../src/components/scrollableSVG.js');
// jest.dontMock('../src/components/slider.js');
// jest.dontMock('interact.js');

jest.autoMockOff();

var data = [];

var start = 1;
var mid = 6;
var end = 10;

var series = "series";
var value = "value";
var colors = ["red","darkred","limegreen","darkgreen","dodgerblue","darkblue"];

function makeRange(label, start, end) {
  var arr = [];

  for(var i = start; i <= end; i++) {
    var dataObj = {};
    dataObj[series] = label;
    dataObj[value] = i;

    arr.push(dataObj);
  }

  return arr;
}

data = data.concat(makeRange("r1", start, end));
data = data.concat(makeRange("r2", mid, end));

var React = require('react/addons');
var RangeFinder = require('../src/range-finder.js');

var controler = function(){};

var RangeFinderRenderer = React.createClass({
  getInitialState: function() {
    return this.props;
  },

  componentDidMount: function() {
    controler = this.controlState;
  },

  controlState: function(newState) {
    this.setState(newState);
  },

  render: function() {
    return <RangeFinder {...this.state}/>
  }
});

describe('Range Finder', function() {
  var TestUtils = React.addons.TestUtils;

  var scryClass = TestUtils.scryRenderedDOMComponentsWithClass;
  var findClass = TestUtils.findRenderedDOMComponentWithClass;

  it('Shows value indicators', function() {
    var rangeFinder = TestUtils.renderIntoDocument(
      <RangeFinderRenderer 
        id="yearSelector"
        data={data}
        rowLabelProperties={series}
        valueProperty={value}
        colors={colors}/>
    );

    var newStart = start + 1;
    var newEnd = end - 1;

    var indicators = scryClass(rangeFinder, 'rf-value-indeicators');
    expect(indicators.length).toBe(0);

    var newRange = {start: newStart};
    controler({selectedRange: newRange});
    indicators = scryClass(rangeFinder, 'rf-value-indeicators');
    expect(indicators.length).toBe(1);

    newRange = {start: newStart, end: newEnd};
    controler({selectedRange: newRange});
    indicators = scryClass(rangeFinder, 'rf-value-indeicators');
    expect(indicators.length).toBe(2);

    newRange = {end: newEnd};
    controler({selectedRange: newRange});
    indicators = scryClass(rangeFinder, 'rf-value-indeicators');
    expect(indicators.length).toBe(1);

    newRange = {};
    controler({selectedRange: newRange});
    indicators = scryClass(rangeFinder, 'rf-value-indeicators');
    expect(indicators.length).toBe(0);
  });

  it('Shows proper data density', function() {
    var rangeFinder = TestUtils.renderIntoDocument(
      <RangeFinderRenderer 
        id="yearSelector"
        data={data}
        rowLabelProperties={series}
        valueProperty={value}
        colors={colors}/>
    );

    var density = findClass(rangeFinder, 'rf-density-label').props.children;
{'fraction_non_alphanumeric': 0.16169470009520787, 'fraction_numerical': 0.004125674389082831, 'mean_word_length': 3.7677760968229954, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '6485105', 'n_tokens_mistral': 2060, 'n_tokens_neox': 2039, 'n_words': 363}