mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Fix spec failures due to slight changes in DOM positioning
This commit is contained in:
@@ -76,10 +76,10 @@ describe "LinesYardstick", ->
|
||||
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([0, 0])).toEqual({left: 0, top: 0})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([0, 1])).toEqual({left: 7, top: 0})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([0, 5])).toEqual({left: 37.8046875, top: 0})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([1, 6])).toEqual({left: 43.20703125, top: 14})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([1, 9])).toEqual({left: 72.20703125, top: 14})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([2, Infinity])).toEqual({left: 288.046875, top: 28})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([0, 5])).toEqual({left: 37.78125, top: 0})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([1, 6])).toEqual({left: 43.171875, top: 14})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([1, 9])).toEqual({left: 72.171875, top: 14})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([2, Infinity])).toEqual({left: 287.859375, top: 28})
|
||||
|
||||
it "reuses already computed pixel positions unless it is invalidated", ->
|
||||
atom.styles.addStyleSheet """
|
||||
@@ -105,9 +105,9 @@ describe "LinesYardstick", ->
|
||||
|
||||
linesYardstick.invalidateCache()
|
||||
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([1, 2])).toEqual({left: 24.00390625, top: 14})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([2, 6])).toEqual({left: 72.01171875, top: 28})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([5, 10])).toEqual({left: 120.01171875, top: 70})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([1, 2])).toEqual({left: 24, top: 14})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([2, 6])).toEqual({left: 72, top: 28})
|
||||
expect(linesYardstick.pixelPositionForScreenPosition([5, 10])).toEqual({left: 120, top: 70})
|
||||
|
||||
it "correctly handles RTL characters", ->
|
||||
atom.styles.addStyleSheet """
|
||||
@@ -156,7 +156,7 @@ describe "LinesYardstick", ->
|
||||
expect(linesYardstick.screenPositionForPixelPosition({top: 32, left: 24.3})).toEqual([2, 3])
|
||||
expect(linesYardstick.screenPositionForPixelPosition({top: 46, left: 66.5})).toEqual([3, 9])
|
||||
expect(linesYardstick.screenPositionForPixelPosition({top: 80, left: 99.9})).toEqual([5, 14])
|
||||
expect(linesYardstick.screenPositionForPixelPosition({top: 80, left: 224.4365234375})).toEqual([5, 29])
|
||||
expect(linesYardstick.screenPositionForPixelPosition({top: 80, left: 224.2365234375})).toEqual([5, 29])
|
||||
expect(linesYardstick.screenPositionForPixelPosition({top: 80, left: 225})).toEqual([5, 30])
|
||||
|
||||
it "clips pixel positions above buffer start", ->
|
||||
|
||||
@@ -3482,12 +3482,14 @@ describe "TextEditorComponent", ->
|
||||
|
||||
editor.moveRight()
|
||||
nextAnimationFrame()
|
||||
right = wrapperNode.pixelPositionForScreenPosition([0, 6]).left
|
||||
|
||||
margin = component.presenter.getHorizontalScrollMarginInPixels()
|
||||
right = wrapperNode.pixelPositionForScreenPosition([0, 4]).left + margin
|
||||
expect(wrapperNode.getScrollRight()).toBeCloseTo right, 0
|
||||
|
||||
editor.moveRight()
|
||||
nextAnimationFrame()
|
||||
right = wrapperNode.pixelPositionForScreenPosition([0, 7]).left
|
||||
right = wrapperNode.pixelPositionForScreenPosition([0, 5]).left + margin
|
||||
expect(wrapperNode.getScrollRight()).toBeCloseTo right, 0
|
||||
|
||||
it "scrolls left when the last cursor gets closer than ::horizontalScrollMargin to the left of the editor", ->
|
||||
@@ -3499,12 +3501,14 @@ describe "TextEditorComponent", ->
|
||||
|
||||
editor.moveLeft()
|
||||
nextAnimationFrame()
|
||||
left = wrapperNode.pixelPositionForScreenPosition([6, 59]).left
|
||||
|
||||
margin = component.presenter.getHorizontalScrollMarginInPixels()
|
||||
left = wrapperNode.pixelPositionForScreenPosition([6, 61]).left - margin
|
||||
expect(wrapperNode.getScrollLeft()).toBeCloseTo left, 0
|
||||
|
||||
editor.moveLeft()
|
||||
nextAnimationFrame()
|
||||
left = wrapperNode.pixelPositionForScreenPosition([6, 58]).left
|
||||
left = wrapperNode.pixelPositionForScreenPosition([6, 60]).left - margin
|
||||
expect(wrapperNode.getScrollLeft()).toBeCloseTo left, 0
|
||||
|
||||
it "scrolls down when inserting lines makes the document longer than the editor's height", ->
|
||||
|
||||
Reference in New Issue
Block a user