TreeView's move-up/down responds to core:move-up/down

This commit is contained in:
Nathan Sobo
2012-10-04 12:10:59 -10:00
parent ae224ca515
commit 082a666a92
2 changed files with 13 additions and 13 deletions

View File

@@ -318,7 +318,7 @@ describe "TreeView", ->
describe "when a collapsed directory is selected", ->
it "skips to the next directory", ->
treeView.root.find('.directory:eq(0)').click()
treeView.trigger 'move-down'
treeView.trigger 'core:move-down'
expect(treeView.root.find('.directory:eq(1)')).toHaveClass 'selected'
describe "when an expanded directory is selected", ->
@@ -327,7 +327,7 @@ describe "TreeView", ->
subdir.expand()
subdir.click()
treeView.trigger 'move-down'
treeView.trigger 'core:move-down'
expect(subdir.entries.find('.entry:first')).toHaveClass 'selected'
@@ -337,7 +337,7 @@ describe "TreeView", ->
subdir1.expand()
subdir1.entries.find('.entry:last').click()
treeView.trigger 'move-down'
treeView.trigger 'core:move-down'
expect(treeView.root.find('.entries > .entry:eq(2)')).toHaveClass 'selected'
@@ -353,14 +353,14 @@ describe "TreeView", ->
describe "when the directory is collapsed", ->
it "selects the entry after its grandparent directory", ->
treeView.trigger 'move-down'
treeView.trigger 'core:move-down'
expect(nested.next()).toHaveClass 'selected'
describe "when the directory is expanded", ->
it "selects the entry after its grandparent directory", ->
nested2.expand()
nested2.find('.file').remove() # kill the .gitkeep file, which has to be there but screws the test
treeView.trigger 'move-down'
treeView.trigger 'core:move-down'
expect(nested.next()).toHaveClass 'selected'
describe "when the last entry of the last directory is selected", ->
@@ -368,11 +368,11 @@ describe "TreeView", ->
lastEntry = treeView.root.find('> .entries .entry:last')
lastEntry.click()
treeView.trigger 'move-down'
treeView.trigger 'core:move-down'
expect(lastEntry).toHaveClass 'selected'
describe "move-up", ->
describe "core:move-up", ->
describe "when there is an expanded directory before the currently selected entry", ->
it "selects the last entry in the expanded directory", ->
lastDir = treeView.root.find('.directory:last').view()
@@ -380,7 +380,7 @@ describe "TreeView", ->
lastDir.expand()
fileAfterDir.click()
treeView.trigger 'move-up'
treeView.trigger 'core:move-up'
expect(lastDir.find('.entry:last')).toHaveClass 'selected'
describe "when there is an entry before the currently selected entry", ->
@@ -388,7 +388,7 @@ describe "TreeView", ->
lastEntry = treeView.root.find('.entry:last')
lastEntry.click()
treeView.trigger 'move-up'
treeView.trigger 'core:move-up'
expect(lastEntry.prev()).toHaveClass 'selected'
@@ -398,14 +398,14 @@ describe "TreeView", ->
subdir.expand()
subdir.find('> .entries > .entry:first').click()
treeView.trigger 'move-up'
treeView.trigger 'core:move-up'
expect(subdir).toHaveClass 'selected'
describe "when there is no parent directory or previous entry", ->
it "does not change the selection", ->
treeView.root.click()
treeView.trigger 'move-up'
treeView.trigger 'core:move-up'
expect(treeView.root).toHaveClass 'selected'
describe "movement outside of viewable region", ->

View File

@@ -46,8 +46,8 @@ class TreeView extends View
initialize: (@rootView) ->
@on 'click', '.entry', (e) => @entryClicked(e)
@on 'move-up', => @moveUp()
@on 'move-down', => @moveDown()
@on 'core:move-up', => @moveUp()
@on 'core:move-down', => @moveDown()
@on 'tree-view:expand-directory', => @expandDirectory()
@on 'tree-view:collapse-directory', => @collapseDirectory()
@on 'tree-view:open-selected-entry', => @openSelectedEntry(true)