 
     beforeEach ->
       config.set "core.hideGitIgnoredFiles", false
-      ignoreFile = fs.join(require.resolve('fixtures/tree-view'), '.gitignore')
+      ignoreFile = fs.join(fs.resolveOnLoadPath('fixtures/tree-view'), '.gitignore')
       fs.write(ignoreFile, 'tree-view.js')
       git.getPathStatus(ignoreFile)
 
-      newFile = fs.join(require.resolve('fixtures/tree-view/dir2'), 'new2')
+      newFile = fs.join(fs.resolveOnLoadPath('fixtures/tree-view/dir2'), 'new2')
       fs.write(newFile, '')
       git.getPathStatus(newFile)
 
-      modifiedFile = fs.join(require.resolve('fixtures/tree-view/dir1'), 'file1')
+      modifiedFile = fs.join(fs.resolveOnLoadPath('fixtures/tree-view/dir1'), 'file1')
       originalFileContent = fs.read(modifiedFile)
       fs.write modifiedFile, 'ch ch changes'
       git.getPathStatus(modifiedFile)


      sampleJs.trigger clickEvent(originalEvent: { detail: 1 })
      expect(sampleJs).toHaveClass 'selected'
      expect(rootView.getActiveView().getPath()).toBe require.resolve('fixtures/tree-view/tree-view.js')
      expect(rootView.getActiveView().isFocused).toBeFalsy()

      sampleTxt.trigger clickEvent(originalEvent: { detail: 1 })
      expect(sampleTxt).toHaveClass 'selected'
      expect(treeView.find('.selected').length).toBe 1
      expect(rootView.getActiveView().getPath()).toBe require.resolve('fixtures/tree-view/tree-view.txt')
      expect(rootView.getActiveView().isFocused).toBeFalsy()

  describe "when a file is double-clicked", ->
    it "selects the file and opens it in the active editor on the first click, then changes focus to the active editor on the second", ->
      sampleJs.trigger clickEvent(originalEvent: { detail: 1 })
      expect(sampleJs).toHaveClass 'selected'
      expect(rootView.getActiveView().getPath()).toBe require.resolve('fixtures/tree-view/tree-view.js')
      expect(rootView.getActiveView().isFocused).toBeFalsy()

      sampleJs.trigger clickEvent(originalEvent: { detail: 2 })

    temporaryFilePath = null

    beforeEach ->
      temporaryFilePath = fs.join(fs.resolveOnLoadPath('fixtures/tree-view'), 'temporary')
      if fs.exists(temporaryFilePath)
        fs.remove(temporaryFilePath)
        waits(20)
