<commit_before>import React from 'react';
import { expect } from 'chai';
import sinon from 'sinon-sandbox';
import { shallow } from 'enzyme';

import DayPickerNavigation from '../../src/components/DayPickerNavigation';
import { VERTICAL_SCROLLABLE } from '../../src/constants';

describe('DayPickerNavigation', () => {
  describe('#render', () => {
    it('renders two role="button" divs', () => {
      const wrapper = shallow(<DayPickerNavigation />).dive();
      expect(wrapper.find('[role="button"]')).to.have.lengthOf(2);
    });

    it('renders one button when vertically scrollable', () => {
      const wrapper = shallow(<DayPickerNavigation orientation={VERTICAL_SCROLLABLE} />).dive();
      expect(wrapper.find('[role="button"]')).to.have.lengthOf(1);
    });

    it('tabindex is present when the default buttons are used', () => {
      const wrapper = shallow(<DayPickerNavigation />).dive();
      const prevMonthButton = wrapper.find('[role="button"]').at(0);
      const nextMonthButton = wrapper.find('[role="button"]').at(1);
      expect(prevMonthButton.prop('tabIndex')).to.equal('0');
      expect(nextMonthButton.prop('tabIndex')).to.equal('0');
    });

    it('tabindex is present when custom buttons are used', () => {
      const wrapper = shallow(<DayPickerNavigation navNext={<div />} navPrev={<div />} />).dive();
      const prevMonthButton = wrapper.find('[role="button"]').at(0);
      const nextMonthButton = wrapper.find('[role="button"]').at(1);
      expect(prevMonthButton.prop('tabIndex')).to.equal('0');
      expect(nextMonthButton.prop('tabIndex')).to.equal('0');
    });
  });

  describe('interactions', () => {
    it('props.onPrevMonthClick is triggered by prev month button click', () => {
      const onPrevMonthStub = sinon.stub();
      const prevMonthButton = shallow(<DayPickerNavigation
        onPrevMonthClick={onPrevMonthStub}
      />).dive().find('[role="button"]').at(0);
      prevMonthButton.simulate('click');
      expect(onPrevMonthStub).to.have.property('callCount', 1);
    });

    it('props.onNextMonthClick is triggered by next month button click', () => {
      const onNextMonthStub = sinon.stub();
      const nextMonthButton = shallow(<DayPickerNavigation
        onNextMonthClick={onNextMonthStub}
      />).dive().find('[role="button"]').at(1);
      nextMonthButton.simulate('click');<commit_msg>adjust existing tests and add new test<commit_after>import React from 'react';
import { expect } from 'chai';
import sinon from 'sinon-sandbox';
import { shallow } from 'enzyme';

import DayPickerNavigation from '../../src/components/DayPickerNavigation';
import { VERTICAL_SCROLLABLE } from '../../src/constants';

describe('DayPickerNavigation', () => {
  describe('#render', () => {
    it('renders two role="button" divs', () => {
      const wrapper = shallow(<DayPickerNavigation />).dive();
      expect(wrapper.find('[role="button"]')).to.have.lengthOf(2);
    });

    it('renders one button when vertically scrollable', () => {
      const wrapper = shallow(<DayPickerNavigation orientation={VERTICAL_SCROLLABLE} />).dive();
      expect(wrapper.find('[role="button"]')).to.have.lengthOf(1);
    });

    it('tabindex is present when the default buttons are used', () => {
      const wrapper = shallow(<DayPickerNavigation />).dive();
      const prevMonthButton = wrapper.find('[role="button"]').at(0);
      const nextMonthButton = wrapper.find('[role="button"]').at(1);
      expect(prevMonthButton.prop('tabIndex')).to.equal('0');
      expect(nextMonthButton.prop('tabIndex')).to.equal('0');
    });

    it('tabindex is not present when custom buttons are used', () => {
      const wrapper = shallow(<DayPickerNavigation navNext={<div />} navPrev={<div />} />).dive();
      const prevMonthButton = wrapper.find('[role="button"]').at(0);
      const nextMonthButton = wrapper.find('[role="button"]').at(1);
      expect(prevMonthButton.prop('tabIndex')).to.equal(undefined);
      expect(nextMonthButton.prop('tabIndex')).to.equal(undefined);
    });

    it('tabindex is present when custom buttons are used and provide a tabIndex', () => {
      const wrapper = shallow(
        <DayPickerNavigation
          navNext={<div id="navNext" tabIndex="0" />} // eslint-disable-line jsx-a11y/no-noninteractive-tabindex
          navPrev={<div id="navPrev" tabIndex="0" />} // eslint-disable-line jsx-a11y/no-noninteractive-tabindex
        />,
      ).dive();
      const prevMonthButton = wrapper.find('#navPrev');
      const nextMonthButton = wrapper.find('#navNext');
      expect(prevMonthButton.prop('tabIndex')).to.equal('0');
      expect(nextMonthButton.prop('tabIndex')).to.equal('0');
    });
  });

  describe('interactions', () => {
    it('props.onPrevMonthClick is triggered by prev month button click', () => {
      const onPrevMonthStub = sinon.stub();
      const prevMonthButton = shallow(<DayPickerNavigation
        onPrevMonthClick={onPrevMonthStub}
      />).dive().find('[role="button"]').at(0);
      prevMonthButton.simulate('click');
      expect(onPrevMonthStub).to.have.property('callCount', 1);
    });

    it('props.onNextMonthClick is triggered by next month button click', () => {
      const onNextMonthStub = sinon.stub();
      const nextMonthButton = shallow(<DayPickerNavigation
        onNextMonthClick={onNextMonthStub}
      />).dive().find('[role="button"]').at(1);
      nextMonthButton.simulate('click');
{'fraction_non_alphanumeric': 0.18076498712762046, 'fraction_numerical': 0.005884516366311144, 'mean_word_length': 4.00828729281768, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 41, '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': '5553949', 'n_tokens_mistral': 1601, 'n_tokens_neox': 1599, 'n_words': 295}