           expect(fs.absolute(treeView.root.getPath())).toBe fs.absolute(projectPath)
           expect(treeView.root.parent()).toMatchSelector(".tree-view")
 
-
     describe "when the root view is opened to a file path", ->
       it "does not attach to the root view but does create a root node when initialized", ->
         atom.packages.deactivatePackage("tree-view")
         atom.packages.packageStates = {}
         atom.workspaceView.openSync('tree-view.js')
-        treeView = atom.packages.activatePackage("tree-view").mainModule.createView()
-        expect(treeView.hasParent()).toBeFalsy()
-        expect(treeView.root).toExist()
+
+        waitsForPromise ->
+          atom.packages.activatePackage('tree-view')
+
+        runs ->
+          treeView = atom.packages.getActivePackage("tree-view").mainModule.createView()
+          expect(treeView.hasParent()).toBeFalsy()
+          expect(treeView.root).toExist()
 
     describe "when the root view is opened to a directory", ->
       it "attaches to the root view", ->
-        treeView = atom.packages.activatePackage("tree-view").mainModule.createView()
-        expect(treeView.hasParent()).toBeTruthy()
-        expect(treeView.root).toExist()
+        waitsForPromise ->
+          atom.packages.activatePackage('tree-view')
+
+        runs ->
+          treeView = atom.packages.getActivePackage("tree-view").mainModule.createView()
+          expect(treeView.hasParent()).toBeTruthy()
+          expect(treeView.root).toExist()
 
     describe "when the project is a .git folder", ->
       it "does not create the tree view", ->


      runs ->
        atom.packages.deactivatePackage("tree-view")
        atom.packages.activatePackage("tree-view")
        treeView = atom.workspaceView.find(".tree-view").view()

        expect(treeView).toExist()
        expect(treeView.selectedEntry()).toMatchSelector(".file:contains(tree-view.js)")
        expect(treeView.find(".directory:contains(dir1)")).toHaveClass("expanded")

    it "restores the focus state of the tree view", ->
      atom.workspaceView.attachToDom()
      treeView.focus()
      expect(treeView.list).toMatchSelector ':focus'
      atom.packages.deactivatePackage("tree-view")
      atom.packages.activatePackage("tree-view")
      treeView = atom.workspaceView.find(".tree-view").view()
      expect(treeView.list).toMatchSelector ':focus'

    it "restores the scroll top when toggled", ->
      atom.workspaceView.height(5)


      atom.project.setPath(rootDirPath)

      waitsForPromise ->
        atom.packages.activatePackage('tree-view')

      runs ->
        atom.workspaceView.trigger 'tree-view:toggle'
        treeView = atom.workspaceView.find(".tree-view").view()
        dirView = treeView.root.entries.find('.directory:contains(test-dir)').view()
        dirView.expand()
        fileView = treeView.find('.file:contains(test-file.txt)').view()

    describe "tree-view:add", ->
      addDialog = null
