Move specs for toggleLineCommentsInSelection to edit-session-spec

This commit is contained in:
Nathan Sobo
2012-06-12 16:22:18 -06:00
parent 426eeb5abe
commit b44a0b69a9
3 changed files with 24 additions and 26 deletions

View File

@@ -880,6 +880,7 @@ describe "EditSession", ->
editSession.delete()
expect(buffer.lineForRow(1)).toBe ' var sort = function(it) {'
expect(buffer.lineForRow(2)).toBe 'if (items.length <= 1) return items;'
expect(editSession.getSelection().isEmpty()).toBeTruthy()
describe "when there are multiple selections", ->
describe "when selections are on the same line", ->
@@ -1043,6 +1044,28 @@ describe "EditSession", ->
expect(buffer.lineForRow(2)).toBe " if (items.length <= 1) return items;"
expect(editSession.getSelectedBufferRange()).toEqual [[0, 1], [3, 15 - tabLength]]
describe ".toggleLineCommentsInSelection()", ->
it "toggles comments on the selected lines", ->
editSession.setSelectedBufferRange([[4, 5], [7, 5]])
editSession.toggleLineCommentsInSelection()
expect(buffer.lineForRow(4)).toBe "// while(items.length > 0) {"
expect(buffer.lineForRow(5)).toBe "// current = items.shift();"
expect(buffer.lineForRow(6)).toBe "// current < pivot ? left.push(current) : right.push(current);"
expect(buffer.lineForRow(7)).toBe "// }"
expect(editSession.getSelectedBufferRange()).toEqual [[4, 7], [7, 7]]
editSession.toggleLineCommentsInSelection()
expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {"
expect(buffer.lineForRow(5)).toBe " current = items.shift();"
expect(buffer.lineForRow(6)).toBe " current < pivot ? left.push(current) : right.push(current);"
expect(buffer.lineForRow(7)).toBe " }"
it "preserves selection emptiness", ->
editSession.setSelectedBufferRange([[4, 0], [4, 0]])
editSession.toggleLineCommentsInSelection()
expect(editSession.getSelection().isEmpty()).toBeTruthy()
describe ".undo() and .redo()", ->
it "undoes/redoes the last change", ->
editSession.insertText("foo")

View File

@@ -171,31 +171,6 @@ describe "Selection", ->
selection.selectToScreenPosition([0, 25])
expect(selection.isReversed()).toBeFalsy()
describe ".toggleLineComments()", ->
it "toggles comments on the selected lines", ->
selection.setBufferRange([[4, 5], [7, 5]])
selection.toggleLineComments()
expect(buffer.lineForRow(4)).toBe "// while(items.length > 0) {"
expect(buffer.lineForRow(5)).toBe "// current = items.shift();"
expect(buffer.lineForRow(6)).toBe "// current < pivot ? left.push(current) : right.push(current);"
expect(buffer.lineForRow(7)).toBe "// }"
expect(selection.getBufferRange()).toEqual [[4, 7], [7, 7]]
selection.toggleLineComments()
expect(buffer.lineForRow(4)).toBe " while(items.length > 0) {"
expect(buffer.lineForRow(5)).toBe " current = items.shift();"
expect(buffer.lineForRow(6)).toBe " current < pivot ? left.push(current) : right.push(current);"
expect(buffer.lineForRow(7)).toBe " }"
it "preserves selection emptiness", ->
editor.attachToDom()
selection.setBufferRange([[4, 0], [4, 0]])
selection.toggleLineComments()
expect(selection.isEmpty()).toBeTruthy()
expect(selectionView.find('.selection')).not.toExist()
describe "when the selection ends on the begining of a fold line", ->
beforeEach ->
editor.createFold(2,4)

View File

@@ -144,7 +144,7 @@ class EditSession
outdentSelectedRows: ->
@mutateSelectedText (selection) -> selection.outdentSelectedRows()
toggleCommentsInSelection: ->
toggleLineCommentsInSelection: ->
@mutateSelectedText (selection) -> selection.toggleLineComments()
cutToEndOfLine: ->