       describe "when no results exist", ->
         beforeEach ->
           projectFindView.findEditor.setText('notintheprojectbro')
+          spyOn(project, 'scan').andCallFake -> new $.Deferred().done()
+
 
         it "displays no errors and no results", ->
           projectFindView.trigger 'core:confirm'
-
-          waitsForPromise ->
-            searchPromise
-
-          runs ->
-            expect(projectFindView.errorMessages).not.toBeVisible()
-            expect(projectFindView.resultsView).toBeVisible()
-            expect(projectFindView.resultsView.find("li > ul > li")).toHaveLength(0)
+          expect(projectFindView.errorMessages).not.toBeVisible()
+          expect(projectFindView.resultsView).toBeVisible()
+          expect(projectFindView.resultsView.find("li > ul > li")).toHaveLength(0)
 
     describe "history", ->
       beforeEach ->
         rootView.trigger 'project-find:show'
+        spyOn(project, 'scan').andCallFake -> new $.Deferred().done()
         projectFindView.findEditor.setText('sort')
         projectFindView.findEditor.trigger 'core:confirm'
-
-        waitsForPromise ->
-          searchPromise
-
-        runs ->
-          projectFindView.findEditor.setText('items')
-          projectFindView.findEditor.trigger 'core:confirm'
-
-        waitsForPromise ->
-          searchPromise
+        projectFindView.findEditor.setText('items')
+        projectFindView.findEditor.trigger 'core:confirm'
 
       it "can navigate the entire history stack", ->
         expect(projectFindView.findEditor.getText()).toEqual 'items'

      beforeEach ->
        editor.trigger 'project-find:show'
        projectFindView.findEditor.setText('i(\\w)ems+')

      it "toggles regex option via an event and finds files matching the pattern", ->
        expect(projectFindView.regexOptionButton).not.toHaveClass('selected')
        projectFindView.trigger 'project-find:toggle-regex-option'
        expect(projectFindView.regexOptionButton).toHaveClass('selected')

        waitsForPromise ->
          searchPromise

        runs ->
          projectFindView.resultsView.scrollToBottom() # To load ALL the results
          expect(projectFindView.resultsView.find("li > ul > li")).toHaveLength(13)
          expect(projectFindView.previewCount.text()).toBe "13 matches in 2 files"

      it "toggles regex option via a button and finds files matching the pattern", ->
        expect(projectFindView.regexOptionButton).not.toHaveClass('selected')
        projectFindView.regexOptionButton.click()
        expect(projectFindView.regexOptionButton).toHaveClass('selected')

        waitsForPromise ->
          searchPromise

        runs ->
          projectFindView.resultsView.scrollToBottom() # To load ALL the results
          expect(projectFindView.resultsView.find("li > ul > li")).toHaveLength(13)
          expect(projectFindView.previewCount.text()).toBe "13 matches in 2 files"

    describe "case sensitivity", ->
      beforeEach ->
        editor.trigger 'project-find:show'

      it "runs a case insensitive search by default", ->
        projectFindView.findEditor.setText('ITEMS')
        projectFindView.trigger 'core:confirm'

        waitsForPromise ->
          searchPromise

        runs ->
          projectFindView.resultsView.scrollToBottom() # To load ALL the results
          expect(projectFindView.resultsView.find("li > ul > li")).toHaveLength(13)
          expect(projectFindView.previewCount.text()).toBe "13 matches in 2 files"

      it "toggles case sensitive option via an event and finds files matching the pattern", ->
        projectFindView.findEditor.setText('C')
        expect(projectFindView.caseOptionButton).not.toHaveClass('selected')
        projectFindView.trigger 'project-find:toggle-case-option'
        expect(projectFindView.caseOptionButton).toHaveClass('selected')

        waitsForPromise ->
          searchPromise

        runs ->
          expect(projectFindView.resultsView.find("li > ul > li")).toHaveLength(1)
          expect(projectFindView.previewCount.text()).toBe "1 match in 1 file"

      it "toggles case sensitive option via a button and finds files matching the pattern", ->
        projectFindView.findEditor.setText('C')
        expect(projectFindView.caseOptionButton).not.toHaveClass('selected')
        projectFindView.caseOptionButton.click()
        expect(projectFindView.caseOptionButton).toHaveClass('selected')

        waitsForPromise ->
          searchPromise

        runs ->
          expect(projectFindView.resultsView.find("li > ul > li")).toHaveLength(1)
          expect(projectFindView.previewCount.text()).toBe "1 match in 1 file"

    describe "when core:confirm is triggered", ->
      beforeEach ->

            expect(projectFindView.resultsView.find("li > ul > li")).toHaveLength(13)
            expect(projectFindView.previewCount.text()).toBe "13 matches in 2 files"

        it "only searches paths matching text in the path filter", ->
          spyOn(project, 'scan').andCallFake -> new $.Deferred().done()
          projectFindView.pathsEditor.setText('*.js')
          projectFindView.trigger 'core:confirm'

          expect(project.scan.argsForCall[0][1]['paths']).toEqual ['*.js']

        it "updates the results list when a buffer changes", ->
          projectFindView.trigger 'core:confirm'
