mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Move specs for toggleLineCommentsInSelection to edit-session-spec
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -144,7 +144,7 @@ class EditSession
|
||||
outdentSelectedRows: ->
|
||||
@mutateSelectedText (selection) -> selection.outdentSelectedRows()
|
||||
|
||||
toggleCommentsInSelection: ->
|
||||
toggleLineCommentsInSelection: ->
|
||||
@mutateSelectedText (selection) -> selection.toggleLineComments()
|
||||
|
||||
cutToEndOfLine: ->
|
||||
|
||||
Reference in New Issue
Block a user