diff --git a/spec/atom/editor-spec.coffee b/spec/atom/editor-spec.coffee index ba6f150f9..f9b68e012 100644 --- a/spec/atom/editor-spec.coffee +++ b/spec/atom/editor-spec.coffee @@ -15,8 +15,6 @@ describe "Editor", -> editor.setBuffer(buffer) describe ".setBuffer", -> - beforeEach -> - it "creates a pre element for each line in the buffer, with the html-escaped text of the line", -> expect(editor.lines.find('pre').length).toEqual(buffer.numLines()) expect(buffer.getLine(2)).toContain('<') @@ -30,21 +28,30 @@ describe "Editor", -> expect(editor.getPosition()).toEqual(row: 0, col: 0) describe "cursor movement", -> - it "moves the cursor when arrow keys are pressed", -> - editor.trigger keydownEvent('right') - expect(editor.getPosition()).toEqual(row: 0, col: 1) + describe ".setPosition({row, col})", -> + it "moves the cursor to cover the character at the given row and column", -> + editor.attachToDom() + editor.setPosition(row: 2, col: 2) - editor.trigger keydownEvent('down') - expect(editor.getPosition()).toEqual(row: 1, col: 1) + expect(editor.cursor.position().top).toBe(2 * editor.lineHeight) + expect(editor.cursor.position().left).toBe(2 * editor.charWidth) - editor.trigger keydownEvent('left') - expect(editor.getPosition()).toEqual(row: 1, col: 0) + describe "when the arrow keys are pressed", -> + it "moves the cursor by a single row/column", -> + editor.trigger keydownEvent('right') + expect(editor.getPosition()).toEqual(row: 0, col: 1) - editor.trigger keydownEvent('up') - expect(editor.getPosition()).toEqual(row: 0, col: 0) + editor.trigger keydownEvent('down') + expect(editor.getPosition()).toEqual(row: 1, col: 1) + + editor.trigger keydownEvent('left') + expect(editor.getPosition()).toEqual(row: 1, col: 0) + + editor.trigger keydownEvent('up') + expect(editor.getPosition()).toEqual(row: 0, col: 0) describe "vertical movement", -> - describe "scroll margins", -> + describe "auto-scrolling", -> beforeEach -> editor.attachToDom() editor.focus() @@ -70,7 +77,7 @@ describe "Editor", -> editor.moveUp() expect(editor.scrollTop()).toBe(0) - it "sacrifices margins when there isn't enough height", -> + it "reduces scroll margins when there isn't enough height to maintain them and scroll smoothly", -> editor.height(editor.lineHeight * 5) _.times 3, -> editor.moveDown() @@ -79,38 +86,6 @@ describe "Editor", -> editor.moveUp() expect(editor.scrollTop()).toBe(0) - describe "when up is pressed on the first line", -> - it "moves the cursor to the beginning of the line, but retains the goal column", -> - editor.setPosition(row: 0, col: 4) - editor.moveUp() - expect(editor.getPosition()).toEqual(row: 0, col: 0) - - editor.moveDown() - expect(editor.getPosition()).toEqual(row: 1, col: 4) - - describe "when down is pressed on the last line", -> - it "moves the cursor to the end of line, but retains the goal column", -> - lastLineIndex = buffer.getLines().length - 1 - lastLine = buffer.getLine(lastLineIndex) - expect(lastLine.length).toBeGreaterThan(0) - - editor.setPosition(row: lastLineIndex, col: 1) - editor.moveDown() - expect(editor.getPosition()).toEqual(row: lastLineIndex, col: lastLine.length) - - editor.moveUp() - expect(editor.getPosition().col).toBe 1 - - it "retains a goal column of 0", -> - lastLineIndex = buffer.getLines().length - 1 - lastLine = buffer.getLine(lastLineIndex) - expect(lastLine.length).toBeGreaterThan(0) - - editor.setPosition(row: lastLineIndex, col: 0) - editor.moveDown() - editor.moveUp() - expect(editor.getPosition().col).toBe 0 - describe "goal column retention", -> lineLengths = null @@ -158,47 +133,70 @@ describe "Editor", -> editor.moveDown() expect(editor.getPosition().col).toBe 6 - describe "when left is pressed on the first column", -> - describe "when there is a previous line", -> - it "wraps to the end of the previous line", -> - editor.setPosition(row: 1, col: 0) - editor.moveLeft() - expect(editor.getPosition()).toEqual(row: 0, col: buffer.getLine(0).length) - - describe "when the cursor is on the first line", -> - it "remains in the same position (0,0)", -> - editor.setPosition(row: 0, col: 0) - editor.moveLeft() + describe "when up is pressed on the first line", -> + it "moves the cursor to the beginning of the line, but retains the goal column", -> + editor.setPosition(row: 0, col: 4) + editor.moveUp() expect(editor.getPosition()).toEqual(row: 0, col: 0) - describe "when right is pressed on the last column", -> - describe "when there is a subsequent line", -> - it "wraps to the beginning of the next line", -> - editor.setPosition(row: 0, col: buffer.getLine(0).length) - editor.moveRight() - expect(editor.getPosition()).toEqual(row: 1, col: 0) + editor.moveDown() + expect(editor.getPosition()).toEqual(row: 1, col: 4) - describe "when the cursor is on the last line", -> - it "remains in the same position", -> + describe "when down is pressed on the last line", -> + it "moves the cursor to the end of line, but retains the goal column", -> lastLineIndex = buffer.getLines().length - 1 lastLine = buffer.getLine(lastLineIndex) expect(lastLine.length).toBeGreaterThan(0) - lastPosition = { row: lastLineIndex, col: lastLine.length } - editor.setPosition(lastPosition) - editor.moveRight() + editor.setPosition(row: lastLineIndex, col: 1) + editor.moveDown() + expect(editor.getPosition()).toEqual(row: lastLineIndex, col: lastLine.length) - expect(editor.getPosition()).toEqual(lastPosition) + editor.moveUp() + expect(editor.getPosition().col).toBe 1 + it "retains a goal column of 0", -> + lastLineIndex = buffer.getLines().length - 1 + lastLine = buffer.getLine(lastLineIndex) + expect(lastLine.length).toBeGreaterThan(0) - describe ".setPosition({row, col})", -> - it "moves the cursor to cover the character at the given row and column", -> - editor.attachToDom() - editor.setPosition(row: 2, col: 2) + editor.setPosition(row: lastLineIndex, col: 0) + editor.moveDown() + editor.moveUp() + expect(editor.getPosition().col).toBe 0 - expect(editor.cursor.position().top).toBe(2 * editor.lineHeight) - expect(editor.cursor.position().left).toBe(2 * editor.charWidth) + describe "horizontal movement", -> + describe "when left is pressed on the first column", -> + describe "when there is a previous line", -> + it "wraps to the end of the previous line", -> + editor.setPosition(row: 1, col: 0) + editor.moveLeft() + expect(editor.getPosition()).toEqual(row: 0, col: buffer.getLine(0).length) + describe "when the cursor is on the first line", -> + it "remains in the same position (0,0)", -> + editor.setPosition(row: 0, col: 0) + editor.moveLeft() + expect(editor.getPosition()).toEqual(row: 0, col: 0) + + describe "when right is pressed on the last column", -> + describe "when there is a subsequent line", -> + it "wraps to the beginning of the next line", -> + editor.setPosition(row: 0, col: buffer.getLine(0).length) + editor.moveRight() + expect(editor.getPosition()).toEqual(row: 1, col: 0) + + describe "when the cursor is on the last line", -> + it "remains in the same position", -> + lastLineIndex = buffer.getLines().length - 1 + lastLine = buffer.getLine(lastLineIndex) + expect(lastLine.length).toBeGreaterThan(0) + + lastPosition = { row: lastLineIndex, col: lastLine.length } + editor.setPosition(lastPosition) + editor.moveRight() + + expect(editor.getPosition()).toEqual(lastPosition) describe "when the editor is attached to the dom", -> it "updates the pixel position of the cursor", -> diff --git a/static/jasmine.css b/static/jasmine.css index 6583fe7c6..72301db23 100644 --- a/static/jasmine.css +++ b/static/jasmine.css @@ -1,14 +1,15 @@ -body { +.jasmine_reporter { font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; + font-size: 16px; } .jasmine_reporter a:visited, .jasmine_reporter a { - color: #303; + color: #303; } .jasmine_reporter a:hover, .jasmine_reporter a:active { - color: blue; + color: blue; } .run_spec { @@ -59,7 +60,7 @@ body { } .suite .suite { - margin: 5px; + margin: 5px; } .suite.passed {