Skip to content

Commit

Permalink
handled all navigation test cases when list is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Silviu Avram committed Jan 8, 2019
1 parent bb4e224 commit 4fe3478
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/__tests__/downshift.get-input-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,29 @@ test('manages arrow up and down behavior', () => {
)
})

test('arrow key down events do nothing when no items are rendered', () => {
const {arrowDownInput, childrenSpy} = renderDownshift({items: []})
// ↓↓
arrowDownInput()
test('navigation key down events do nothing when no items are rendered', () => {
const {arrowDownInput, arrowUpInput, endOnInput, homeOnInput, childrenSpy} = renderDownshift({items: []})
// ↓ ↓ ↑ end home
arrowDownInput() // open dropdown, nothing highlighted if no options
expect(childrenSpy).toHaveBeenLastCalledWith(
expect.objectContaining({highlightedIndex: null}),
)
arrowDownInput()
expect(childrenSpy).toHaveBeenLastCalledWith(
expect.objectContaining({highlightedIndex: null}),
)
arrowUpInput()
expect(childrenSpy).toHaveBeenLastCalledWith(
expect.objectContaining({highlightedIndex: null}),
)
endOnInput()
expect(childrenSpy).toHaveBeenLastCalledWith(
expect.objectContaining({highlightedIndex: null}),
)
homeOnInput()
expect(childrenSpy).toHaveBeenLastCalledWith(
expect.objectContaining({highlightedIndex: null}),
)
})

test('arrow up on a closed menu opens the menu and highlights last option', () => {
Expand Down

0 comments on commit 4fe3478

Please sign in to comment.