Port .selectLinesContainingCursors() specs

This commit is contained in:
Antonio Scandurra
2015-09-23 09:57:06 +02:00
parent 57a006d19b
commit 7f3160eba6
3 changed files with 19 additions and 14 deletions

View File

@@ -3393,6 +3393,19 @@ describe "TextEditorComponent", ->
afterEach ->
atom.themes.removeStylesheet("test")
describe "when selecting lines containing cursors", ->
it "autoscrolls to the selection", ->
editor.setCursorScreenPosition([5, 6])
nextAnimationFrame()
wrapperNode.scrollToTop()
nextAnimationFrame()
expect(wrapperNode.getScrollTop()).toBe 0
editor.selectLinesContainingCursors()
nextAnimationFrame()
expect(wrapperNode.getScrollBottom()).toBe (7 + editor.getVerticalScrollMargin()) * 10
describe "moving cursors", ->
it "scrolls down when the last cursor gets closer than ::verticalScrollMargin to the bottom of the editor", ->
expect(wrapperNode.getScrollTop()).toBe 0

View File

@@ -1194,20 +1194,6 @@ describe "TextEditor", ->
editor.selectLinesContainingCursors()
expect(editor.getSelectedBufferRange()).toEqual [[1, 0], [4, 0]]
it "autoscrolls to the selection", ->
editor.setLineHeightInPixels(10)
editor.setDefaultCharWidth(10)
editor.setHeight(50)
editor.setWidth(50)
editor.setHorizontalScrollbarHeight(0)
editor.setCursorScreenPosition([5, 6])
editor.scrollToTop()
expect(editor.getScrollTop()).toBe 0
editor.selectLinesContainingCursors()
expect(editor.getScrollBottom()).toBe (7 + editor.getVerticalScrollMargin()) * 10
describe ".selectToBeginningOfWord()", ->
it "selects text from cusor position to beginning of word", ->
editor.setCursorScreenPosition [0, 13]

View File

@@ -231,6 +231,12 @@ class TextEditorElement extends HTMLElement
setScrollBottom: (scrollBottom) ->
@component.setScrollBottom(scrollBottom)
scrollToTop: ->
@setScrollTop(0)
scrollToBottom: ->
@setScrollBottom(Infinity)
getScrollTop: ->
@component.getScrollTop()