Skip to content

Fix flaky failing test #1050

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions test/datepicker_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,14 @@ describe('DatePicker', () => {
})

it('should update the preSelection state when a day is selected with mouse click', () => {
var data = getOnInputKeyDownStuff({shouldCloseOnSelect: false})
var day = TestUtils.findRenderedDOMComponentWithClass(data.datePicker.calendar, 'react-datepicker__day--today')
// Note: We need monthsShown=2 so that today can still be clicked when
// ArrowLeft selects the previous month. (On the 1st 2 days of the month.)
var data = getOnInputKeyDownStuff({shouldCloseOnSelect: false, monthsShown: 2})

TestUtils.Simulate.keyDown(data.nodeInput, {key: 'ArrowLeft', keyCode: 37, which: 37})
TestUtils.Simulate.keyDown(data.nodeInput, {key: 'ArrowLeft', keyCode: 37, which: 37})

var day = TestUtils.findRenderedDOMComponentWithClass(data.datePicker.calendar, 'react-datepicker__day--today')
TestUtils.Simulate.click(ReactDOM.findDOMNode(day))

TestUtils.Simulate.keyDown(data.nodeInput, {key: 'ArrowDown', keyCode: 40, which: 40})
Expand Down Expand Up @@ -322,6 +326,7 @@ describe('DatePicker', () => {
filterDate={opts.filterDate}
minDate={opts.minDate}
maxDate={opts.maxDate}
monthsShown={opts.monthsShown}
shouldCloseOnSelect={opts.shouldCloseOnSelect}/>
)
var dateInput = datePicker.input
Expand Down