From 0bb173b646b154859add799091ddf37884c30653 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Tue, 11 Nov 2014 11:20:30 -0800 Subject: [PATCH] Add spec for creation and removal of overlay --- spec/text-editor-component-spec.coffee | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/spec/text-editor-component-spec.coffee b/spec/text-editor-component-spec.coffee index 030bba37d..1af24641d 100644 --- a/spec/text-editor-component-spec.coffee +++ b/spec/text-editor-component-spec.coffee @@ -1196,6 +1196,28 @@ describe "TextEditorComponent", -> expect(componentNode.querySelector('.test-highlight')).toBeFalsy() expect(componentNode.querySelector('.new-test-highlight')).toBeTruthy() + describe "overlay decoration rendering", -> + [marker, decoration, decorationParams, scrollViewClientLeft] = [] + beforeEach -> + scrollViewClientLeft = componentNode.querySelector('.scroll-view').getBoundingClientRect().left + + it "renders an overlay decoration when added and removes the overlay when the decoration is destroyed", -> + item = document.createElement('div') + item.classList.add 'my-overlay' + + marker = editor.displayBuffer.markBufferRange([[2, 13], [2, 13]], invalidate: 'never') + decoration = editor.decorateMarker(marker, {type: 'overlay', item}) + nextAnimationFrame() + + overlay = component.getTopmostDOMNode().querySelector('atom-overlay .my-overlay') + expect(overlay).toBe item + + decoration.destroy() + nextAnimationFrame() + + overlay = component.getTopmostDOMNode().querySelector('atom-overlay .my-overlay') + expect(overlay).toBe null + describe "hidden input field", -> it "renders the hidden input field at the position of the last cursor if the cursor is on screen and the editor is focused", -> editor.setVerticalScrollMargin(0)