Skip to content

Commit db64f07

Browse files
aijmartijnrusschen
authored andcommitted
Fix flaky failing test (Hacker0x01#1050)
1 parent 99d6879 commit db64f07

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

test/datepicker_test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,14 @@ describe('DatePicker', () => {
151151
})
152152

153153
it('should update the preSelection state when a day is selected with mouse click', () => {
154-
var data = getOnInputKeyDownStuff({shouldCloseOnSelect: false})
155-
var day = TestUtils.findRenderedDOMComponentWithClass(data.datePicker.calendar, 'react-datepicker__day--today')
154+
// Note: We need monthsShown=2 so that today can still be clicked when
155+
// ArrowLeft selects the previous month. (On the 1st 2 days of the month.)
156+
var data = getOnInputKeyDownStuff({shouldCloseOnSelect: false, monthsShown: 2})
157+
156158
TestUtils.Simulate.keyDown(data.nodeInput, {key: 'ArrowLeft', keyCode: 37, which: 37})
157159
TestUtils.Simulate.keyDown(data.nodeInput, {key: 'ArrowLeft', keyCode: 37, which: 37})
160+
161+
var day = TestUtils.findRenderedDOMComponentWithClass(data.datePicker.calendar, 'react-datepicker__day--today')
158162
TestUtils.Simulate.click(ReactDOM.findDOMNode(day))
159163

160164
TestUtils.Simulate.keyDown(data.nodeInput, {key: 'ArrowDown', keyCode: 40, which: 40})
@@ -322,6 +326,7 @@ describe('DatePicker', () => {
322326
filterDate={opts.filterDate}
323327
minDate={opts.minDate}
324328
maxDate={opts.maxDate}
329+
monthsShown={opts.monthsShown}
325330
shouldCloseOnSelect={opts.shouldCloseOnSelect}/>
326331
)
327332
var dateInput = datePicker.input

0 commit comments

Comments
 (0)