Port leftover specs from DisplayBuffer

This commit is contained in:
Antonio Scandurra 2015-09-24 11:41:02 +02:00
parent 270334b713
commit 99e77dc09d
2 changed files with 34 additions and 41 deletions

View File

@ -718,21 +718,6 @@ describe "DisplayBuffer", ->
expect(displayBuffer.clipScreenPosition([0, 1], clip: 'forward')).toEqual [0, tabLength]
expect(displayBuffer.clipScreenPosition([0, tabLength], clip: 'forward')).toEqual [0, tabLength]
describe "::screenPositionForPixelPosition(pixelPosition)", ->
it "clips pixel positions above buffer start", ->
displayBuffer.setLineHeightInPixels(20)
expect(displayBuffer.screenPositionForPixelPosition(top: -Infinity, left: -Infinity)).toEqual [0, 0]
expect(displayBuffer.screenPositionForPixelPosition(top: -Infinity, left: Infinity)).toEqual [0, 0]
expect(displayBuffer.screenPositionForPixelPosition(top: -1, left: Infinity)).toEqual [0, 0]
expect(displayBuffer.screenPositionForPixelPosition(top: 0, left: Infinity)).toEqual [0, 29]
it "clips pixel positions below buffer end", ->
displayBuffer.setLineHeightInPixels(20)
expect(displayBuffer.screenPositionForPixelPosition(top: Infinity, left: -Infinity)).toEqual [12, 2]
expect(displayBuffer.screenPositionForPixelPosition(top: Infinity, left: Infinity)).toEqual [12, 2]
expect(displayBuffer.screenPositionForPixelPosition(top: displayBuffer.getHeight() + 1, left: 0)).toEqual [12, 2]
expect(displayBuffer.screenPositionForPixelPosition(top: displayBuffer.getHeight() - 1, left: 0)).toEqual [12, 0]
describe "::screenPositionForBufferPosition(bufferPosition, options)", ->
it "clips the specified buffer position", ->
expect(displayBuffer.screenPositionForBufferPosition([0, 2])).toEqual [0, 2]
@ -1247,32 +1232,6 @@ describe "DisplayBuffer", ->
expect(scrollSpy).toHaveBeenCalledWith(screenRange: [[8, 20], [8, 20]], options: {center: true})
expect(scrollSpy).toHaveBeenCalledWith(screenRange: [[8, 20], [8, 20]], options: {center: false, reversed: true})
describe "::getVisibleRowRange()", ->
beforeEach ->
displayBuffer.setLineHeightInPixels(10)
displayBuffer.setHeight(100)
it "returns the first and the last visible rows", ->
displayBuffer.setScrollTop(0)
expect(displayBuffer.getVisibleRowRange()).toEqual [0, 9]
it "includes partially visible rows in the range", ->
displayBuffer.setScrollTop(5)
expect(displayBuffer.getVisibleRowRange()).toEqual [0, 10]
it "returns an empty range when lineHeight is 0", ->
displayBuffer.setLineHeightInPixels(0)
expect(displayBuffer.getVisibleRowRange()).toEqual [0, 0]
it "ends at last buffer row even if there's more space available", ->
displayBuffer.setHeight(150)
displayBuffer.setScrollTop(60)
expect(displayBuffer.getVisibleRowRange()).toEqual [0, 13]
describe "::decorateMarker", ->
describe "when decorating gutters", ->
[marker] = []

View File

@ -3605,6 +3605,40 @@ describe "TextEditorComponent", ->
nextAnimationFrame()
expect(wrapperNode.getScrollTop()).toBe 0
describe "::screenPositionForPixelPosition(pixelPosition)", ->
it "clips pixel positions above buffer start", ->
expect(component.screenPositionForPixelPosition(top: -Infinity, left: -Infinity)).toEqual [0, 0]
expect(component.screenPositionForPixelPosition(top: -Infinity, left: Infinity)).toEqual [0, 0]
expect(component.screenPositionForPixelPosition(top: -1, left: Infinity)).toEqual [0, 0]
expect(component.screenPositionForPixelPosition(top: 0, left: Infinity)).toEqual [0, 29]
it "clips pixel positions below buffer end", ->
expect(component.screenPositionForPixelPosition(top: Infinity, left: -Infinity)).toEqual [12, 2]
expect(component.screenPositionForPixelPosition(top: Infinity, left: Infinity)).toEqual [12, 2]
expect(component.screenPositionForPixelPosition(top: component.getScrollHeight() + 1, left: 0)).toEqual [12, 2]
expect(component.screenPositionForPixelPosition(top: component.getScrollHeight() - 1, left: 0)).toEqual [12, 0]
describe "::getVisibleRowRange()", ->
beforeEach ->
wrapperNode.style.height = lineHeightInPixels * 8 + "px"
component.measureDimensions()
nextAnimationFrame()
it "returns the first and the last visible rows", ->
component.setScrollTop(0)
nextAnimationFrame()
expect(component.getVisibleRowRange()).toEqual [0, 9]
it "ends at last buffer row even if there's more space available", ->
wrapperNode.style.height = lineHeightInPixels * 13 + "px"
component.measureDimensions()
nextAnimationFrame()
component.setScrollTop(60)
nextAnimationFrame()
expect(component.getVisibleRowRange()).toEqual [0, 13]
describe "middle mouse paste on Linux", ->
originalPlatform = null