mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Decorations can be flashed
This commit is contained in:
@@ -887,12 +887,12 @@ describe "EditorComponent", ->
|
||||
expect(lineAndLineNumberHaveClass(3, 'only-non-empty')).toBe false
|
||||
|
||||
describe "highlight decoration rendering", ->
|
||||
[marker, decoration, scrollViewClientLeft] = []
|
||||
[marker, decoration, decorationParams, scrollViewClientLeft] = []
|
||||
beforeEach ->
|
||||
scrollViewClientLeft = node.querySelector('.scroll-view').getBoundingClientRect().left
|
||||
marker = editor.displayBuffer.markBufferRange([[2, 13], [3, 15]], invalidate: 'inside')
|
||||
decoration = {type: 'highlight', class: 'test-highlight'}
|
||||
editor.addDecorationForMarker(marker, decoration)
|
||||
decorationParams = {type: 'highlight', class: 'test-highlight'}
|
||||
decoration = editor.addDecorationForMarker(marker, decorationParams)
|
||||
runSetImmediateCallbacks()
|
||||
|
||||
it "does not render highlights for off-screen lines until they come on-screen", ->
|
||||
@@ -929,7 +929,7 @@ describe "EditorComponent", ->
|
||||
expect(regions.length).toBe 2
|
||||
|
||||
it "removes highlights when a decoration is removed", ->
|
||||
editor.removeDecorationForMarker(marker, decoration)
|
||||
editor.removeDecorationForMarker(marker, decorationParams)
|
||||
runSetImmediateCallbacks()
|
||||
regions = node.querySelectorAll('.test-highlight .region')
|
||||
expect(regions.length).toBe 0
|
||||
@@ -960,6 +960,40 @@ describe "EditorComponent", ->
|
||||
regions = node.querySelectorAll('.test-highlight .region')
|
||||
expect(regions.length).toBe 2
|
||||
|
||||
describe "flashing a decoration via the Decoration.flash()", ->
|
||||
highlightNode = null
|
||||
flashClass = 'flashClass'
|
||||
beforeEach ->
|
||||
highlightNode = node.querySelector('.test-highlight')
|
||||
|
||||
it "adds and removes the flash class specified in ::flash", ->
|
||||
expect(highlightNode.classList.contains(flashClass)).toBe false
|
||||
|
||||
decoration.flash(flashClass, 10)
|
||||
expect(highlightNode.classList.contains(flashClass)).toBe true
|
||||
|
||||
advanceClock(10)
|
||||
expect(highlightNode.classList.contains(flashClass)).toBe false
|
||||
|
||||
describe "when ::flash is called again before the first has finished", ->
|
||||
it "removes the class from the decoration highlight before adding it for the second ::flash call", ->
|
||||
decoration.flash(flashClass, 10)
|
||||
expect(highlightNode.classList.contains(flashClass)).toBe true
|
||||
|
||||
addClassSpy = spyOn(highlightNode.classList, 'add').andCallThrough()
|
||||
removeClassSpy = spyOn(highlightNode.classList, 'remove').andCallThrough()
|
||||
|
||||
advanceClock(2)
|
||||
decoration.flash(flashClass, 10)
|
||||
|
||||
expect(removeClassSpy).toHaveBeenCalledWith(flashClass)
|
||||
expect(addClassSpy).toHaveBeenCalledWith(flashClass)
|
||||
|
||||
expect(highlightNode.classList.contains(flashClass)).toBe true
|
||||
|
||||
advanceClock(10)
|
||||
expect(highlightNode.classList.contains(flashClass)).toBe false
|
||||
|
||||
describe "when a decoration's marker moves", ->
|
||||
it "moves rendered highlights when the buffer is changed", ->
|
||||
regionStyle = node.querySelector('.test-highlight .region').style
|
||||
|
||||
Reference in New Issue
Block a user