Skip to content

Commit

Permalink
💚 Make sure more tests waits for a frame to have been requested
Browse files Browse the repository at this point in the history
  • Loading branch information
abe33 committed Jun 26, 2015
1 parent ca8f4e3 commit 1c81a5f
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions spec/minimap-element-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,8 @@ describe 'MinimapElement', ->
beforeEach ->
spyOn(minimapElement, 'requestForcedUpdate').andCallThrough()
atom.config.set 'minimap.textOpacity', 0.3
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'requests a complete update', ->
expect(minimapElement.requestForcedUpdate).toHaveBeenCalled()
Expand All @@ -604,7 +605,8 @@ describe 'MinimapElement', ->
beforeEach ->
spyOn(minimapElement, 'requestForcedUpdate').andCallThrough()
atom.config.set 'minimap.displayCodeHighlights', true
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'requests a complete update', ->
expect(minimapElement.requestForcedUpdate).toHaveBeenCalled()
Expand All @@ -613,7 +615,8 @@ describe 'MinimapElement', ->
beforeEach ->
spyOn(minimapElement, 'requestForcedUpdate').andCallThrough()
atom.config.set 'minimap.charWidth', 1
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'requests a complete update', ->
expect(minimapElement.requestForcedUpdate).toHaveBeenCalled()
Expand All @@ -622,7 +625,8 @@ describe 'MinimapElement', ->
beforeEach ->
spyOn(minimapElement, 'requestForcedUpdate').andCallThrough()
atom.config.set 'minimap.charHeight', 1
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'requests a complete update', ->
expect(minimapElement.requestForcedUpdate).toHaveBeenCalled()
Expand All @@ -631,7 +635,8 @@ describe 'MinimapElement', ->
beforeEach ->
spyOn(minimapElement, 'requestForcedUpdate').andCallThrough()
atom.config.set 'minimap.interline', 2
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'requests a complete update', ->
expect(minimapElement.requestForcedUpdate).toHaveBeenCalled()
Expand Down Expand Up @@ -670,7 +675,8 @@ describe 'MinimapElement', ->
atom.config.set 'editor.preferredLineLength', 2

atom.config.set 'minimap.adjustMinimapWidthToSoftWrap', true
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'adjusts the width of the minimap canvas', ->
expect(minimapElement.canvas.width / devicePixelRatio).toEqual(4)
Expand Down Expand Up @@ -703,7 +709,8 @@ describe 'MinimapElement', ->
beforeEach ->
editor.setText(mediumSample)
editor.setScrollTop(50)
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

atom.config.set 'minimap.minimapScrollIndicator', true

Expand All @@ -727,7 +734,8 @@ describe 'MinimapElement', ->
describe 'and then disabled', ->
beforeEach ->
atom.config.set 'minimap.adjustMinimapWidthToSoftWrap', false
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'adjusts the width of the minimap', ->
expect(minimapElement.offsetWidth).toBeCloseTo(editorElement.offsetWidth / 11, -1)
Expand All @@ -737,8 +745,7 @@ describe 'MinimapElement', ->
beforeEach ->
atom.config.set 'minimap.preferredLineLength', 16384
waitsFor -> minimapElement.frameRequested
runs ->
nextAnimationFrame()
runs -> nextAnimationFrame()

it 'adjusts the width of the minimap', ->
expect(minimapElement.offsetWidth).toBeCloseTo(editorElement.offsetWidth / 11, -1)
Expand All @@ -748,7 +755,8 @@ describe 'MinimapElement', ->
beforeEach ->
editor.setText(mediumSample)
editor.setScrollTop(50)
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

atom.config.set 'minimap.minimapScrollIndicator', true

Expand Down Expand Up @@ -783,15 +791,17 @@ describe 'MinimapElement', ->
describe 'when the minimap cannot scroll', ->
beforeEach ->
editor.setText(smallSample)
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'removes the scroll indicator', ->
expect(minimapElement.shadowRoot.querySelector('.minimap-scroll-indicator')).not.toExist()

describe 'and then can scroll again', ->
beforeEach ->
editor.setText(largeSample)
nextAnimationFrame()
waitsFor -> minimapElement.frameRequested
runs -> nextAnimationFrame()

it 'attaches the scroll indicator', ->
expect(minimapElement.shadowRoot.querySelector('.minimap-scroll-indicator')).toExist()
Expand All @@ -809,7 +819,6 @@ describe 'MinimapElement', ->
expect(minimapElement.classList.contains('absolute')).toBeTruthy()
expect(minimapElement.classList.contains('left')).toBeTruthy()


# ####### ## ## #### ###### ## ##
# ## ## ## ## ## ## ## ## ##
# ## ## ## ## ## ## ## ##
Expand Down

0 comments on commit 1c81a5f

Please sign in to comment.