       selectList.attachToDom()
 
     it "filters the elements in the list based on the scoreElement function and selects the first item", ->
-      miniEditor.getEditor().insertText('la')
+      editorView.getEditor().insertText('la')
       window.advanceClock(selectList.inputThrottle)
 
       expect(list.find('li').length).toBe 2

      expect(selectList.error).not.toBeVisible()

    it "displays an error if there are no matches, removes error when there are matches", ->
      miniEditor.getEditor().insertText('nothing will match this')
      window.advanceClock(selectList.inputThrottle)

      expect(list.find('li').length).toBe 0
      expect(selectList.error).not.toBeHidden()

      miniEditor.getEditor().setText('la')
      window.advanceClock(selectList.inputThrottle)

      expect(list.find('li').length).toBe 2
      expect(selectList.error).not.toBeVisible()

    it "displays no elements until the array has been set on the list", ->
      selectList.array = null
      selectList.list.empty()
      miniEditor.getEditor().insertText('la')
      window.advanceClock(selectList.inputThrottle)

      expect(list.find('li').length).toBe 0
      expect(selectList.error).toBeHidden()
      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'

      miniEditor.trigger 'core:move-up'

      expect(list.find('li:first')).not.toHaveClass 'selected'
      expect(list.find('li:last')).toHaveClass 'selected'

      miniEditor.trigger 'core:move-down'

      expect(list.find('li:first')).toHaveClass 'selected'
      expect(list.find('li:last')).not.toHaveClass 'selected'

      miniEditor.trigger 'core:move-down'

      expect(list.find('li:eq(0)')).not.toHaveClass 'selected'
      expect(list.find('li:eq(1)')).toHaveClass 'selected'

      miniEditor.trigger 'core:move-down'

      expect(list.find('li:eq(1)')).not.toHaveClass 'selected'
      expect(list.find('li:eq(2)')).toHaveClass 'selected'

      miniEditor.trigger 'core:move-up'

      expect(list.find('li:eq(2)')).not.toHaveClass 'selected'
      expect(list.find('li:eq(1)')).toHaveClass 'selected'

      itemHeight = list.find('li').outerHeight()
      list.height(itemHeight * 2)

      editorView.trigger 'core:move-down'
      editorView.trigger 'core:move-down'
      expect(list.scrollBottom()).toBe itemHeight * 3

      editorView.trigger 'core:move-down'
      expect(list.scrollBottom()).toBe itemHeight * 4

      editorView.trigger 'core:move-up'
      editorView.trigger 'core:move-up'
      expect(list.scrollTop()).toBe itemHeight

  describe "the core:confirm event", ->
    describe "when there is an item selected (because the list in not empty)", ->
      it "triggers the selected hook with the selected array element", ->
        editorView.trigger 'core:move-down'
        editorView.trigger 'core:move-down'
        editorView.trigger 'core:confirm'
        expect(selectList.confirmed).toHaveBeenCalledWith(items[2])

    describe "when there is no item selected (because the list is empty)", ->
      beforeEach ->
        selectList.attachToDom()

      it "does not trigger the confirmed hook", ->
        editorView.getEditor().insertText("i will never match anything")
        window.advanceClock(selectList.inputThrottle)

        expect(list.find('li')).not.toExist()
        editorView.trigger 'core:confirm'
        expect(selectList.confirmed).not.toHaveBeenCalled()

      it "does trigger the cancelled hook", ->
        editorView.getEditor().insertText("i will never match anything")
        window.advanceClock(selectList.inputThrottle)

        expect(list.find('li')).not.toExist()
        editorView.trigger 'core:confirm'
        expect(selectList.cancelled).toHaveBeenCalled()

  describe "when a list item is clicked", ->
