Introduce instance method tests

pull/2903/head
Andrew Watkins 2018-02-28 14:55:44 -07:00
parent 6b85a0b541
commit 2128d5f2e9
1 changed files with 27 additions and 0 deletions

View File

@ -93,6 +93,33 @@ describe('Components.Shared.Dropdown', () => {
expect(dropdown.state().filteredItems).toEqual([{text: 'foo'}])
})
})
describe('handleFilterChange', () => {
it('resets filteredList and searchTerm if the filter is empty', () => {
const {dropdown} = setup({items, useAutoComplete: true})
const event = {target: {value: ''}}
dropdown.instance().applyFilter('fo')
// assert that the list is filtered
expect(dropdown.state().filteredItems).toEqual([{text: 'foo'}])
dropdown.instance().handleFilterChange(event)
const {filteredItems, searchTerm} = dropdown.state()
expect(filteredItems).toEqual(items)
expect(searchTerm).toEqual('')
})
})
describe('handleClickOutside', () => {
it('sets isOpen to false', () => {
const {dropdown} = setup()
dropdown.simulate('click')
dropdown.instance().handleClickOutside()
expect(dropdown.state().isOpen).toBe(false)
})
})
})
})
})