<commit_before>import React from 'react'
import moment from 'moment'
import Day from '../src/day'
import { shallow } from 'enzyme'

function renderDay (day, props = {}) {
  return shallow(
    <Day day={day} {...props} />
  )
}

describe('Day', () => {
  describe('rendering', () => {
    it('should render the specified day', () => {
      const shallowDay = renderDay(moment())
      expect(shallowDay.hasClass('react-datepicker__day')).to.equal(true)
      expect(shallowDay.text()).to.equal(moment().date() + '')
    })
  })

  describe('selected', () => {
    const className = 'react-datepicker__day--selected'

    it('should apply the selected class if selected', () => {
      const day = moment()
      const shallowDay = renderDay(day, { selected: day })
      expect(shallowDay.hasClass(className)).to.equal(true)
    })

    it('should not apply the selected class if not selected', () => {
      const day = moment()
      const selected = day.clone().add(1, 'day')
      const shallowDay = renderDay(day, { selected })
      expect(shallowDay.hasClass(className)).to.equal(false)
    })
  })

  describe('highlighted', () => {
    const className = 'react-datepicker__day--highlighted'

    it('should apply the highlighted class if in highlighted array', () => {
      const day = moment()
      const highlightDay1 = day.clone()
      const highlightDay2 = day.clone().add(1, 'day')
      const highlightDates = [highlightDay1, highlightDay2]
      const shallowDay = renderDay(day, { highlightDates })
      expect(shallowDay.hasClass(className)).to.equal(true)
    })

    it('should not apply the highlighted class if not in highlighted array', () => {
      const day = moment()
      const highlightDay1 = day.clone().subtract(1, 'day')
      const highlightDay2 = day.clone().add(1, 'day')
      const highlightDates = [highlightDay1, highlightDay2]
      const shallowDay = renderDay(day, { highlightDates })
      expect(shallowDay.hasClass(className)).to.equal(false)
    })
  })<commit_msg>Add keyboard-selected tests (#761)<commit_after>import React from 'react'
import moment from 'moment'
import Day from '../src/day'
import { shallow } from 'enzyme'

function renderDay (day, props = {}) {
  return shallow(
    <Day day={day} {...props} />
  )
}

describe('Day', () => {
  describe('rendering', () => {
    it('should render the specified day', () => {
      const shallowDay = renderDay(moment())
      expect(shallowDay.hasClass('react-datepicker__day')).to.equal(true)
      expect(shallowDay.text()).to.equal(moment().date() + '')
    })
  })

  describe('selected', () => {
    const className = 'react-datepicker__day--selected'

    it('should apply the selected class if selected', () => {
      const day = moment()
      const shallowDay = renderDay(day, { selected: day })
      expect(shallowDay.hasClass(className)).to.equal(true)
    })

    it('should not apply the selected class if not selected', () => {
      const day = moment()
      const selected = day.clone().add(1, 'day')
      const shallowDay = renderDay(day, { selected })
      expect(shallowDay.hasClass(className)).to.equal(false)
    })
  })

  describe('keyboard-selected', () => {
    const className = 'react-datepicker__day--keyboard-selected'

    it('should apply the keyboard-selected class when pre-selected and another day is selected', () => {
      const day = moment()
      const selected = day.clone().add(1, 'day')
      const shallowDay = renderDay(day, { selected, preSelection: day })
      expect(shallowDay.hasClass(className)).to.equal(true)
    })

    it('should not apply the keyboard-selected class when selected', () => {
      const day = moment()
      const shallowDay = renderDay(day, { selected: day, preSelection: day })
      expect(shallowDay.hasClass(className)).to.equal(false)
    })

    it('should not apply the keyboard-selected class when another day is pre-selected', () => {
      const day = moment()
      const selected = day.clone().add(1, 'day')
      const preSelection = day.clone().add(2, 'day')
      const shallowDay = renderDay(day, { selected, preSelection })
      expect(shallowDay.hasClass(className)).to.equal(false)
    })

    it('should not apply the keyboard-selected class if in inline mode', () => {
      const day = moment()
      const selected = day.clone().add(1, 'day')
      const shallowDay = renderDay(day, { selected, preSelection: day, inline: true })
      expect(shallowDay.hasClass(className)).to.equal(false)
    })
  })

  describe('highlighted', () => {
    const className = 'react-datepicker__day--highlighted'

    it('should apply the highlighted class if in highlighted array', () => {
      const day = moment()
      const highlightDay1 = day.clone()
      const highlightDay2 = day.clone().add(1, 'day')
      const highlightDates = [highlightDay1, highlightDay2]
      const shallowDay = renderDay(day, { highlightDates })
      expect(shallowDay.hasClass(className)).to.equal(true)
    })

    it('should not apply the highlighted class if not in highlighted array', () => {
      const day = moment()
      const highlightDay1 = day.clone().subtract(1, 'day')
      const highlightDay2 = day.clone().add(1, 'day')
      const highlightDates = [highlightDay1, highlightDay2]
      const shallowDay = renderDay(day, { highlightDates })
      expect(shallowDay.hasClass(className)).to.equal(false)
    })
  })
{'fraction_non_alphanumeric': 0.1490579977835242, 'fraction_numerical': 0.0057258958256372365, 'mean_word_length': 3.3493975903614457, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 28, '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': '5348841', 'n_tokens_mistral': 1585, 'n_tokens_neox': 1548, 'n_words': 388}