Don't populate list until elements have been set

Closes #174
This commit is contained in:
Kevin Sawicki 2013-01-25 10:28:07 -08:00
parent 73aab4f49a
commit fb4623d5d3
2 changed files with 13 additions and 0 deletions

View File

@ -59,6 +59,17 @@ describe "SelectList", ->
expect(selectList.error).not.toBeVisible()
expect(selectList).not.toHaveClass("error")
it "displays no elements until the array has been set on the list", ->
selectList.array = null
selectList.list.empty()
miniEditor.insertText('la')
window.advanceClock(selectList.inputThrottle)
expect(list.find('li').length).toBe 0
expect(selectList).not.toHaveClass("error")
selectList.setArray(array)
expect(list.find('li').length).toBe 2
describe "when core:move-up / core:move-down are triggered on the miniEditor", ->
it "selects the previous / next item in the list, or wraps around to the other side", ->
expect(list.find('li:first')).toHaveClass 'selected'

View File

@ -62,6 +62,8 @@ class SelectList extends View
@loading.text(message).show()
populateList: ->
return unless @array?
filterQuery = @miniEditor.getText()
if filterQuery.length
filteredArray = fuzzyFilter(@array, filterQuery, key: @filterKey)