         waitsForPromise ->
           searchPromise
 
+        runs ->
+          resultsView = getResultsView()
+
+
       it "renders all results and selects the last item when core:move-to-bottom is triggered; selects the first item when core:move-to-top is triggered", ->
-        resultsView = getResultsView()
         expect(resultsView.find("li").length).toBeLessThan resultsView.getPathCount() + resultsView.getMatchCount()
 
         expect(resultsView.prop('scrollTop')).toBe 0

        expect(resultsView.find("li:last").closest('.path')).toHaveClass 'selected'

      it "selects the path when when core:move-to-bottom is triggered and last item is collapsed", ->
        resultsView = getResultsView()

        atom.commands.dispatch resultsView.element, 'core:move-to-top'
        atom.commands.dispatch resultsView.element, 'core:move-left'
        atom.commands.dispatch resultsView.element, 'core:move-to-top'

        expect(resultsView.prop('scrollTop')).toBe 0

      it "selects the path when when core:move-to-bottom is triggered and last item is collapsed", ->
        atom.commands.dispatch resultsView.element, 'core:move-to-bottom'
        atom.commands.dispatch resultsView.element, 'core:move-left'
        atom.commands.dispatch resultsView.element, 'core:move-to-bottom'
