TreeView scrolls to selected path when move-down or move-up are triggered

This commit is contained in:
Corey Johnson
2012-05-07 10:39:36 -07:00
parent 78d3418c8c
commit 886e2caa52
4 changed files with 40 additions and 5 deletions

View File

@@ -1,3 +1,5 @@
$ = require 'jquery'
_ = require 'underscore'
TreeView = require 'tree-view'
RootView = require 'root-view'
Directory = require 'directory'
@@ -232,6 +234,23 @@ describe "TreeView", ->
treeView.trigger 'move-up'
expect(treeView.root).toHaveClass 'selected'
describe "movement outside of viewable region", ->
it "scrolls the tree view to the selected item", ->
treeView.height(100)
treeView.attachToDom()
$(element).view().expand() for element in treeView.find('.directory')
expect(treeView.prop('scrollHeight')).toBeGreaterThan treeView.outerHeight()
treeView.moveDown()
expect(treeView.scrollTop()).toBe 0
entryCount = treeView.find(".entry").length
_.times entryCount, -> treeView.moveDown()
expect(treeView.scrollBottom()).toBe treeView.prop('scrollHeight')
_.times entryCount, -> treeView.moveUp()
expect(treeView.scrollTop()).toBe 0
describe "tree-view:expand-directory", ->
describe "when a directory entry is selected", ->
it "expands the current directory", ->