       it "squashes three dir names when the first and second only contain single dirs", ->
         if path.sep is '\\'
           # First escape the backslashes for Coffeescript, then escape them for jQuery
-          epsilonDir = $(treeView.roots[0].entries).find(".directory:contains(gamma\\\\delta\\\\epsilon):first")
+          epsilonDir = findDirectoryContainingText(treeView.roots[0], "gamma\\\\delta\\\\epsilon")
         else
-          epsilonDir = $(treeView.roots[0].entries).find(".directory:contains(gamma#{path.sep}delta#{path.sep}epsilon):first")
-        epsilonDir[0].expand()
-        epsilonEntries = [].slice.call(epsilonDir[0].children[1].children).map (element) ->
+          epsilonDir = findDirectoryContainingText(treeView.roots[0], "gamma#{path.sep}delta#{path.sep}epsilon")
+        epsilonDir.expand()
+        epsilonEntries = [].slice.call(epsilonDir.children[1].children).map (element) ->
           element.innerText
 
         expect(epsilonEntries).toEqual(["theta.txt"])
 
       it "does not squash a dir name when there are two child dirs ", ->
-        lambdaDir = $(treeView.roots[0].entries).find('.directory:contains(lambda):first')
-        lambdaDir[0].expand()
-        lambdaEntries = [].slice.call(lambdaDir[0].children[1].children).map (element) ->
+        lambdaDir = findDirectoryContainingText(treeView.roots[0], "lambda")
+        lambdaDir.expand()
+        lambdaEntries = [].slice.call(lambdaDir.children[1].children).map (element) ->
           element.innerText
 
         expect(lambdaEntries).toEqual(["iota", "kappa"])

          fs.makeTreeSync(rhoDirPath)
          treeView.updateRoots()

          omicronDir = $(treeView.roots[0].entries).find(".directory:contains(omicron):first span")[0]
          expect(omicronDir.title).toEqual("omicron")
          omicronDir.dispatchEvent(new MouseEvent('click', {bubbles: true, detail: 1}))
          piDir = $(treeView.roots[0].entries).find(".directory:contains(omicron) .entries .directory:contains(pi) span")[0]
          expect(piDir.title).toEqual("pi")
          rhoDir = $(treeView.roots[0].entries).find(".directory:contains(omicron) .entries .directory:contains(rho) span")[0]
          expect(rhoDir.title).toEqual("rho")

      describe "when a directory is reloaded", ->
        it "squashes the directory names the last of which is same as an unsquashed directory", ->
          muDir = $(treeView.roots[0].entries).find('.directory:contains(mu):first')
          muDir[0].expand()
          muEntries = Array.from(muDir[0].children[1].children).map (element) -> element.innerText
          expect(muEntries).toEqual(["nu#{path.sep}xi", "xi"])

          muDir[0].expand()
          muDir[0].reload()
          muEntries = Array.from(muDir[0].children[1].children).map (element) -> element.innerText
          expect(muEntries).toEqual(["nu#{path.sep}xi", "xi"])

  describe "Git status decorations", ->
    [projectPath, modifiedFile, originalFileContent] = []


        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"])
