From 57e2cf80f40799aa35484f4992f58ea90a38e055 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 4 Apr 2014 12:58:12 -0600 Subject: [PATCH] :lipstick: Reorganize spec --- spec/editor-component-spec.coffee | 55 ++++++++++++++++--------------- 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/spec/editor-component-spec.coffee b/spec/editor-component-spec.coffee index 2affd5114..ab5b20bb8 100644 --- a/spec/editor-component-spec.coffee +++ b/spec/editor-component-spec.coffee @@ -19,28 +19,39 @@ describe "EditorComponent", -> {lineHeightInPixels, charWidth} = component.measureLineDimensions() node = component.getDOMNode() - it "renders only the currently-visible lines", -> - node.style.height = 4.5 * lineHeightInPixels + 'px' - component.updateAllDimensions() + describe "scrolling", -> + it "renders only the currently-visible lines", -> + node.style.height = 4.5 * lineHeightInPixels + 'px' + component.updateAllDimensions() - lines = node.querySelectorAll('.line') - expect(lines.length).toBe 5 - expect(lines[0].textContent).toBe editor.lineForScreenRow(0).text - expect(lines[4].textContent).toBe editor.lineForScreenRow(4).text + lines = node.querySelectorAll('.line') + expect(lines.length).toBe 5 + expect(lines[0].textContent).toBe editor.lineForScreenRow(0).text + expect(lines[4].textContent).toBe editor.lineForScreenRow(4).text - node.querySelector('.vertical-scrollbar').scrollTop = 2.5 * lineHeightInPixels - component.onVerticalScroll() + node.querySelector('.vertical-scrollbar').scrollTop = 2.5 * lineHeightInPixels + component.onVerticalScroll() - expect(node.querySelector('.scrollable-content').style['-webkit-transform']).toBe "translateY(#{-2.5 * lineHeightInPixels}px)" + expect(node.querySelector('.scrollable-content').style['-webkit-transform']).toBe "translateY(#{-2.5 * lineHeightInPixels}px)" - lines = node.querySelectorAll('.line') - expect(lines.length).toBe 5 - expect(lines[0].textContent).toBe editor.lineForScreenRow(2).text - expect(lines[4].textContent).toBe editor.lineForScreenRow(6).text + lines = node.querySelectorAll('.line') + expect(lines.length).toBe 5 + expect(lines[0].textContent).toBe editor.lineForScreenRow(2).text + expect(lines[4].textContent).toBe editor.lineForScreenRow(6).text - spacers = node.querySelectorAll('.spacer') - expect(spacers[0].offsetHeight).toBe 2 * lineHeightInPixels - expect(spacers[1].offsetHeight).toBe (editor.getScreenLineCount() - 7) * lineHeightInPixels + spacers = node.querySelectorAll('.spacer') + expect(spacers[0].offsetHeight).toBe 2 * lineHeightInPixels + expect(spacers[1].offsetHeight).toBe (editor.getScreenLineCount() - 7) * lineHeightInPixels + + it "updates the scroll bar when the scrollTop is changed in the model", -> + node.style.height = 4.5 * lineHeightInPixels + 'px' + component.updateAllDimensions() + + scrollbarNode = node.querySelector('.vertical-scrollbar') + expect(scrollbarNode.scrollTop).toBe 0 + + editor.setScrollTop(10) + expect(scrollbarNode.scrollTop).toBe 10 describe "cursor rendering", -> it "renders the currently visible cursors", -> @@ -151,16 +162,6 @@ describe "EditorComponent", -> expect(region3Rect.left).toBe 0 expect(region3Rect.width).toBe 10 * charWidth - it "updates the scroll bar when the scrollTop is changed in the model", -> - node.style.height = 4.5 * lineHeightInPixels + 'px' - component.updateAllDimensions() - - scrollbarNode = node.querySelector('.vertical-scrollbar') - expect(scrollbarNode.scrollTop).toBe 0 - - editor.setScrollTop(10) - expect(scrollbarNode.scrollTop).toBe 10 - it "transfers focus to the hidden input", -> expect(document.activeElement).toBe document.body node.focus()