       it "squashes two dir names when the first only contains a single dir", ->
         if path.sep is '\\'
           # First escape the backslashes for Coffeescript, then escape them for jQuery
-          betaDir = $(treeView.roots[0].entries).find(".directory:contains(alpha\\\\beta):first")
+          betaDir = findDirectoryContainingText(treeView.roots[0], "alpha\\\\beta")
         else
-          betaDir = $(treeView.roots[0].entries).find(".directory:contains(alpha#{path.sep}beta):first")
-        betaDir[0].expand()
-        betaEntries = [].slice.call(betaDir[0].children[1].children).map (element) ->
+          betaDir = findDirectoryContainingText(treeView.roots[0], "alpha#{path.sep}beta")
+        betaDir.expand()
+        betaEntries = [].slice.call(betaDir.children[1].children).map (element) ->
           element.innerText
 
         expect(betaEntries).toEqual(["beta.txt"])

      describe "when a squashed directory is deleted", ->
        it "un-squashes the directories", ->
          jasmine.attachToDOM(workspaceElement)
          piDir = $(treeView.roots[0].entries).find(".directory:contains(omicron#{path.sep}pi):first")[0]
          treeView.focus()
          treeView.selectEntry(piDir)
          spyOn(atom, 'confirm').andCallFake (dialog) ->
            dialog.buttons["Move to Trash"]()
          atom.commands.dispatch(treeView.element, 'tree-view:remove')

          omicronDir = $(treeView.roots[0].entries).find(".directory:contains(omicron):first span")[0]
          expect(omicronDir.title).toEqual("omicron")

      describe "when a file is created within a directory with another squashed directory", ->
        it "un-squashes the directories", ->
          jasmine.attachToDOM(workspaceElement)
          piDir = $(treeView.roots[0].entries).find(".directory:contains(omicron#{path.sep}pi):first")[0]
          expect(piDir).not.toBeNull()
          # omicron is a squashed dir, so searching for omicron would give us omicron/pi instead
          omicronPath = piDir.getPath().replace "#{path.sep}pi", ""


        rootDirPath = treeView.roots[0].getPath()
        expect(rootDirPath).toBe(rootDir)
        zetaDirPath = findDirectoryContainingText(treeView.roots[0], 'zeta').getPath()
        expect(zetaDirPath).toBe(zetaDir)

      it "does not squash a file in to a DirectoryViews", ->
        zetaDir = findDirectoryContainingText(treeView.roots[0], 'zeta')
        zetaDir.expand()
        zetaEntries = [].slice.call(zetaDir.children[1].children).map (element) ->
          element.innerText

        expect(zetaEntries).toEqual(["zeta.txt"])
