     describe "when dropping a DirectoryView and FileViews onto a DirectoryView's header", ->
       it "should move the files and directory to the hovered directory", ->
         # Dragging alpha.txt and alphaDir into thetaDir
-        rootDir = $(treeView.roots[0])
-
-        alphaFile = rootDir[0].entries.children[2]
-        alphaDir = $(treeView.roots[0].entries).find('.directory:contains(alpha):first')
-        alphaDir[0].expand()
-
-        gammaDir = $(treeView.roots[0].entries).find('.directory:contains(gamma):first')
-        gammaDir[0].expand()
-        thetaDir = $(gammaDir[0].entries).find('.directory:contains(theta):first')
-
-        dragged = [alphaFile, alphaDir[0]]
+        alphaFile = treeView.roots[0].entries.children[2]
+        alphaDir = findDirectoryContainingText(treeView.roots[0], 'alpha')
+        alphaDir.expand()
+
+        gammaDir = findDirectoryContainingText(treeView.roots[0], 'gamma')
+        gammaDir.expand()
+        thetaDir = findDirectoryContainingText(treeView.roots[0], 'theta')
+        thetaDir.expand()
+
+        dragged = [alphaFile, alphaDir]
 
         [dragStartEvent, dragEnterEvent, dropEvent] =
-            eventHelpers.buildInternalDragEvents(dragged, thetaDir.find('.header')[0], thetaDir[0])
+            eventHelpers.buildInternalDragEvents(dragged, thetaDir.querySelector('.header'), thetaDir)
 
         runs ->
           treeView.onDragStart(dragStartEvent)
           treeView.onDrop(dropEvent)
-          expect(thetaDir[0].children.length).toBe 2
+          expect(thetaDir.children.length).toBe 2
 
         waitsFor "directory view contents to refresh", ->
-          $(treeView.roots[0].entries).find('.directory:contains(theta):first .entry').length > 2
-
-        runs ->
-          thetaDir = $(gammaDir[0].entries).find('.directory:contains(theta):first')
-          thetaDir[0].expand()
-          expect(thetaDir.find('.entry').length).toBe 2
+          findDirectoryContainingText(treeView.roots[0], 'theta').querySelectorAll('.entry').length > 2
+
+        runs ->
+          thetaDir.expand()
+          expect(thetaDir.querySelectorAll('.entry').length).toBe 3
           # alpha dir still has all its entries
-          alphaDir = $(thetaDir[0].entries).find('.directory:contains(alpha):first')
-          alphaDir[0].expand()
-          expect(alphaDir.find('.entry').length).toBe 2
+          alphaDir = findDirectoryContainingText(thetaDir.entries, 'alpha')
+          alphaDir.expand()
+          expect(alphaDir.querySelectorAll('.entry').length).toBe 2
 
     describe "when dropping a DirectoryView onto a DirectoryView's header", ->
       beforeEach ->

        deltaFile = gammaDir.entries.children[1]

        [dragStartEvent, dragEnterEvent, dropEvent] =
            eventHelpers.buildInternalDragEvents(deltaFile, alphaDir.querySelector('.header'), alphaDir)

        treeView.onDragStart(dragStartEvent)
        treeView.onDrop(dropEvent)

        gammaFiles = [].slice.call(gammaDir.entries.children, 1, 3)

        [dragStartEvent, dragEnterEvent, dropEvent] =
            eventHelpers.buildInternalDragEvents(gammaFiles, alphaDir.querySelector('.header'), alphaDir)

        runs ->
          treeView.onDragStart(dragStartEvent)
          treeView.onDrop(dropEvent)
          expect(alphaDir.entries.children.length).toBe 2

        waitsFor "directory view contents to refresh", ->
          findDirectoryContainingText(treeView.roots[0], 'alpha').querySelectorAll('.entry').length > 2
