diff --git a/spec/extensions/tree-view-spec.coffee b/spec/extensions/tree-view-spec.coffee index 89982b475..a9cb7d050 100644 --- a/spec/extensions/tree-view-spec.coffee +++ b/spec/extensions/tree-view-spec.coffee @@ -277,7 +277,7 @@ describe "TreeView", -> expect(rootView.activeEditor()).toBeUndefined() describe "file modification", -> - [fileElement, rootDirPath, dirPath, filePath] = [] + [dirView, fileElement, rootDirPath, dirPath, filePath] = [] beforeEach -> treeView.deactivate() @@ -310,6 +310,20 @@ describe "TreeView", -> treeView.trigger "tree-view:add" addDialog = rootView.find(".add-dialog").view() + describe "when a directory is selected", -> + it "opens an add dialog with the directory's path populated", -> + treeView.trigger "tree-view:cancel" + dirView.click() + console.log 'boom' + treeView.trigger "tree-view:add" + + expect(addDialog).toExist() + expect(addDialog.prompt.text()).toBeTruthy() + expect(project.relativize(dirPath)).toMatch(/[^\/]$/) + expect(addDialog.miniEditor.getText()).toBe(project.relativize(dirPath) + "/") + expect(addDialog.miniEditor.getCursorBufferPosition().column).toBe addDialog.miniEditor.getText().length + expect(addDialog.miniEditor.isFocused).toBeTruthy() + describe "when a file is selected", -> it "opens an add dialog with the file's current directory path populated", -> expect(addDialog).toExist() diff --git a/src/extensions/tree-view/directory-view.coffee b/src/extensions/tree-view/directory-view.coffee index 01d72a169..3099c95b7 100644 --- a/src/extensions/tree-view/directory-view.coffee +++ b/src/extensions/tree-view/directory-view.coffee @@ -5,7 +5,7 @@ $ = require 'jquery' module.exports = class DirectoryView extends View @content: ({directory, isExpanded}) -> - @li class: 'directory entry', => + @li class: 'directory entry', path: directory.path, => @div class: 'header', => @span '▸', class: 'disclosure-arrow', outlet: 'disclosureArrow' @span directory.getName(), class: 'name'