 
   describe "go to declaration", ->
     it "doesn't move the cursor when no declaration is found", ->
-      atom.workspaceView.openSync("tagged.js")
-      editor = atom.workspaceView.getActivePaneItem()
-      editor.setCursorBufferPosition([0,2])
-      atom.workspaceView.getActiveView().trigger 'symbols-view:go-to-declaration'
+      waitsForPromise ->
+        atom.workspace.open("tagged.js")
+
+      runs ->
+        editor = atom.workspaceView.getActivePaneItem()
+        editor.setCursorBufferPosition([0,2])
+        atom.workspaceView.getActiveView().trigger 'symbols-view:go-to-declaration'
 
       waitsForPromise ->
         activationPromise

        expect(editor.getCursorBufferPosition()).toEqual [2,0]

    it "displays matches when more than one exists and opens the selected match", ->
      atom.workspaceView.openSync("tagged.js")
      editor = atom.workspaceView.getActivePaneItem()
      editor.setCursorBufferPosition([8,14])
      atom.workspaceView.getActiveView().trigger 'symbols-view:go-to-declaration'

      waitsFor ->
        atom.workspaceView.find('.symbols-view').find('li').length > 0

    describe "when the tag is in a file that doesn't exist", ->
      it "doesn't display the tag", ->
        fs.removeSync(atom.project.resolve("tagged-duplicate.js"))

        waitsForPromise ->
          atom.workspace.open("tagged.js")

        runs ->
          editor = atom.workspaceView.getActivePaneItem()
          editor.setCursorBufferPosition([8,14])
          spyOn(SymbolsView.prototype, "moveToPosition").andCallThrough()
          atom.workspaceView.getActiveView().trigger 'symbols-view:go-to-declaration'

        waitsFor ->
          SymbolsView::moveToPosition.callCount is 1
