Skip to content

Commit

Permalink
test: Add tests for inInputCleared
Browse files Browse the repository at this point in the history
  • Loading branch information
Lennert van Sever authored and Lennert van Sever committed Jul 19, 2023
1 parent cf0d496 commit af93a03
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,23 @@ test('sets search mode on input change', t => {
t.true(wrapper.state().searchModeOn)
})

test('Does not call onInputCleared when there are characters in the input box', t => {
const handler = spy()
const { tree } = t.context
const wrapper = shallow(<DropdownTreeSelect onInputCleared={handler} data={tree} />)
wrapper.instance().onInputChange('it')
t.false(handler.called)
})

test('Calls onInputCleared when the characters in the input box are cleared', t => {
const handler = spy()
const { tree } = t.context
const wrapper = shallow(<DropdownTreeSelect onInputCleared={handler} data={tree} />)
wrapper.instance().onInputChange('it')
wrapper.instance().resetSearchState()
t.true(handler.called)
})

test('hides dropdown onChange for simpleSelect', t => {
const { tree } = t.context
const wrapper = mount(<DropdownTreeSelect id={dropdownId} showDropdown="initial" data={tree} mode="simpleSelect" />)
Expand Down

0 comments on commit af93a03

Please sign in to comment.