Skip to content

Commit

Permalink
🔥 Remove redundant tests
Browse files Browse the repository at this point in the history
The size and position of the controls div is already tested above.
Testing position of the elements inside doesn’t add any value
and using absolute values in the tests when we know that both Chrome
flex box and TravisCI environment aren’t reliable enough to use this
kind of tests.
  • Loading branch information
abe33 committed Feb 15, 2015
1 parent 42efbd6 commit c79dbb8
Showing 1 changed file with 14 additions and 55 deletions.
69 changes: 14 additions & 55 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ describe 'MinimapElement', ->
expect(realOffsetLeft(quickSettingsElement)).toBeCloseTo(minimapBounds.right, 0)

describe 'when the adjustMinimapWidthToSoftWrap setting is enabled', ->
[controls] = []
beforeEach ->
atom.config.set 'editor.softWrap', true
atom.config.set 'editor.softWrapAtPreferredLineLength', true
Expand All @@ -708,65 +709,23 @@ describe 'MinimapElement', ->
atom.config.set('minimap.adjustMinimapWidthToSoftWrap', true)
nextAnimationFrame()

describe 'the open-minimap-quick-settings position', ->
[controls] = []

beforeEach ->
controls = minimapElement.shadowRoot.querySelector('.minimap-controls')
openQuickSettings = minimapElement.shadowRoot.querySelector('.open-minimap-quick-settings')

editorElement.style.width = '1024px'

sleep(150)
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'adjusts the size of the control div to fit in the minimap', ->
expect(controls.clientWidth).toEqual(minimapElement.canvas.clientWidth)

it 'positions the controls div over the canvas', ->
controlsRect = controls.getBoundingClientRect()
canvasRect = minimapElement.canvas.getBoundingClientRect()
expect(controlsRect.left).toEqual(canvasRect.left)
expect(controlsRect.right).toEqual(canvasRect.right)

describe 'positions the open-minimap-quick-settings button', ->
beforeEach ->
atom.config.set 'editor.preferredLineLength', 80
atom.config.set 'minimap.displayMinimapOnLeft', false
editorElement.style.width = '2560px'

sleep(150)
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'right should be less than 2560', ->
openQuickSettingsRect = openQuickSettings.getBoundingClientRect()
minimapRect = minimapElement.getBoundingClientRect()
expect(openQuickSettingsRect.right).toBeLessThan(minimapRect.right)
expect(openQuickSettingsRect.right).toBeLessThan(2560)
expect(openQuickSettingsRect.right).toEqual(2560 - 4)

describe 'positions minimap-scroll-indicator', ->
[scrollIndicator] = []
beforeEach ->
atom.config.set 'editor.preferredLineLength', 80
atom.config.set 'minimap.displayMinimapOnLeft', false
atom.config.set 'minimap.minimapScrollIndicator', true
controls = minimapElement.shadowRoot.querySelector('.minimap-controls')
openQuickSettings = minimapElement.shadowRoot.querySelector('.open-minimap-quick-settings')

scrollIndicator = minimapElement.shadowRoot.querySelector('.minimap-scroll-indicator')
editorElement.style.width = '1024px'

editorElement.style.width = '2560px'
sleep(150)
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

sleep(150)
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()
it 'adjusts the size of the control div to fit in the minimap', ->
expect(controls.clientWidth).toEqual(minimapElement.canvas.clientWidth)

it 'right should be <= 2560', ->
scrollIndicatorRect = scrollIndicator.getBoundingClientRect()
minimapRect = minimapElement.getBoundingClientRect()
expect(scrollIndicatorRect.right).toBeLessThan(minimapRect.right)
expect(scrollIndicatorRect.right).toBeLessThan(2560)
it 'positions the controls div over the canvas', ->
controlsRect = controls.getBoundingClientRect()
canvasRect = minimapElement.canvas.getBoundingClientRect()
expect(controlsRect.left).toEqual(canvasRect.left)
expect(controlsRect.right).toEqual(canvasRect.right)

describe 'when the displayMinimapOnLeft setting is enabled', ->
describe 'clicking on the div', ->
Expand Down

0 comments on commit c79dbb8

Please sign in to comment.