<commit_before>import 'mocha';
import * as React from 'react';
import * as chai from 'chai';
import { shallow } from 'enzyme';
import * as sinon from 'sinon';
import * as sinonChai from 'sinon-chai';
chai.use(sinonChai);
const expect = chai.expect;
import * as moment from 'moment';
import DateVG from './Date';

describe('Search <Date />', () => {
  it('check for inner components', () => {
    const wrapper = shallow(<DateVG />);
    expect(wrapper.find('.date-wrap')).to.have.length(1);
    expect(wrapper.find('.filter')).to.have.length(2);
    expect(wrapper.find('.input')).to.have.length(2);
    expect(wrapper.find('DatePicker')).to.have.length(2);
  });

  it('check if updates filter on change start date', () => {
    const startDate = moment().toDate();
    const filter = sinon.spy((params) => {
      const {
        start,
        end,
      } = params;
      expect(start).to.be.equal(startDate);
    });
    const wrapper = shallow(<DateVG filter={filter} />);
    const instance = wrapper.instance();
    instance['onChangeStart'](undefined, startDate);
  });

  it('check if update filter on change end date', () => {
    const endDate = moment().toDate();
    const filter = sinon.spy((params) => {
      const {
        start,
        end,
      } = params;
      expect(end).to.be.equal(endDate);
    });
    const wrapper = shallow(<DateVG filter={filter} />);
    const instance = wrapper.instance();
    instance['onChangeEnd'](undefined, endDate);
  });

  it('check if date picker before today is disabled', () => {
    const wrongDate = moment().add(-5, 'days').toDate();
    const okDate = moment().add(5, 'days').toDate();
    const wrapper = shallow(<DateVG filter={() => {}} />);
    const instance = wrapper.instance();
    expect(instance['shouldDisableDateStart'](wrongDate)).to.be.true;
    expect(instance['shouldDisableDateEnd'](wrongDate)).to.be.true;
    expect(instance['shouldDisableDateStart'](okDate)).to.be.false;
    expect(instance['shouldDisableDateEnd'](okDate)).to.be.false;
  });

  it('check if date picker is disabled after setting end date', () => {
    const wrongStartDate = moment().add(10, 'days').toDate();
    const okStartDate = moment().add(1, 'days').toDate();
    const endDate = moment().add(5, 'days').toDate();
    const wrapper = shallow(<DateVG filter={() => {}} />);
    const instance = wrapper.instance();
    instance['onChangeEnd'](undefined, endDate);
    expect(instance['shouldDisableDateStart'](wrongStartDate)).to.be.true;
    expect(instance['shouldDisableDateStart'](okStartDate)).to.be.false;
  });

  it('check if date picker is disabled after setting end date', () => {
    const startDate = moment().add(10, 'days').toDate();
    const wrongEndDate = moment().add(5, 'days').toDate();
    const okEndDate = moment().add(15, 'days').toDate();
    const wrapper = shallow(<DateVG filter={() => {}} />);
    const instance = wrapper.instance();
    instance['onChangeStart'](undefined, startDate);
    expect(instance['shouldDisableDateEnd'](wrongEndDate)).to.be.true;
    expect(instance['shouldDisableDateEnd'](okEndDate)).to.be.false;
  });

  it('check if date picker is ok between start and end date', () => {
    const startDate = moment().add(5, 'days').toDate();
    const endDate = moment().add(10, 'days').toDate();
    const okMiddle =  moment().add(7, 'days').toDate();
    const before = moment().add(3, 'days').toDate();
    const after = moment().add(13, 'days').toDate();
    const wrapper = shallow(<DateVG filter={() => {}} />);
    const instance = wrapper.instance();
    instance['onChangeStart'](undefined, startDate);<commit_msg>Improved spec description (issue #77) (#94)<commit_after>import 'mocha';
import * as React from 'react';
import * as chai from 'chai';
import { shallow } from 'enzyme';
import * as sinon from 'sinon';
import * as sinonChai from 'sinon-chai';
chai.use(sinonChai);
const expect = chai.expect;
import * as moment from 'moment';
import DateVG from './Date';

describe('Search <Date />', () => {
  it('check for inner components', () => {
    const wrapper = shallow(<DateVG />);
    expect(wrapper.find('.date-wrap')).to.have.length(1);
    expect(wrapper.find('.filter')).to.have.length(2);
    expect(wrapper.find('.input')).to.have.length(2);
    expect(wrapper.find('DatePicker')).to.have.length(2);
  });

  it('check if choosing the start date works properly', () => {
    const startDate = moment().toDate();
    const filter = sinon.spy((params) => {
      const {
        start,
        end,
      } = params;
      expect(start).to.be.equal(startDate);
    });
    const wrapper = shallow(<DateVG filter={filter} />);
    const instance = wrapper.instance();
    instance['onChangeStart'](undefined, startDate);
  });

  it('check if choosing the end date works properly', () => {
    const endDate = moment().toDate();
    const filter = sinon.spy((params) => {
      const {
        start,
        end,
      } = params;
      expect(end).to.be.equal(endDate);
    });
    const wrapper = shallow(<DateVG filter={filter} />);
    const instance = wrapper.instance();
    instance['onChangeEnd'](undefined, endDate);
  });

  it('check if dates before today are disabled', () => {
    const wrongDate = moment().add(-5, 'days').toDate();
    const okDate = moment().add(5, 'days').toDate();
    const wrapper = shallow(<DateVG filter={() => {}} />);
    const instance = wrapper.instance();
    expect(instance['shouldDisableDateStart'](wrongDate)).to.be.true;
    expect(instance['shouldDisableDateEnd'](wrongDate)).to.be.true;
    expect(instance['shouldDisableDateStart'](okDate)).to.be.false;
    expect(instance['shouldDisableDateEnd'](okDate)).to.be.false;
  });

  it('check if dates after picked end date are disabled', () => {
    const wrongStartDate = moment().add(10, 'days').toDate();
    const okStartDate = moment().add(1, 'days').toDate();
    const endDate = moment().add(5, 'days').toDate();
    const wrapper = shallow(<DateVG filter={() => {}} />);
    const instance = wrapper.instance();
    instance['onChangeEnd'](undefined, endDate);
    expect(instance['shouldDisableDateStart'](wrongStartDate)).to.be.true;
    expect(instance['shouldDisableDateStart'](okStartDate)).to.be.false;
  });

  it('check if dates before picked start date are disabled', () => {
    const startDate = moment().add(10, 'days').toDate();
    const wrongEndDate = moment().add(5, 'days').toDate();
    const okEndDate = moment().add(15, 'days').toDate();
    const wrapper = shallow(<DateVG filter={() => {}} />);
    const instance = wrapper.instance();
    instance['onChangeStart'](undefined, startDate);
    expect(instance['shouldDisableDateEnd'](wrongEndDate)).to.be.true;
    expect(instance['shouldDisableDateEnd'](okEndDate)).to.be.false;
  });

  it('check if dates between picked start and end date are active', () => {
    const startDate = moment().add(5, 'days').toDate();
    const endDate = moment().add(10, 'days').toDate();
    const okMiddle =  moment().add(7, 'days').toDate();
    const before = moment().add(3, 'days').toDate();
    const after = moment().add(13, 'days').toDate();
    const wrapper = shallow(<DateVG filter={() => {}} />);
    const instance = wrapper.instance();
    instance['onChangeStart'](undefined, startDate);
{'fraction_non_alphanumeric': 0.18824496506370736, 'fraction_numerical': 0.006576243321002877, 'mean_word_length': 3.962610469068661, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 47, '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': '1525328', 'n_tokens_mistral': 2261, 'n_tokens_neox': 2219, 'n_words': 483}