mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge remote-tracking branch 'origin/command-extensions' into dev
Conflicts: spec/app/editor-spec.coffee spec/app/root-view-spec.coffee src/app/editor.coffee src/extensions/strip-trailing-whitespace.coffee
This commit is contained in:
@@ -2136,3 +2136,55 @@ describe "Editor", ->
|
||||
expect(editor.reloadGrammar()).toBeFalsy()
|
||||
expect(editor.updateDisplay).not.toHaveBeenCalled()
|
||||
expect(editor.getGrammar().name).toBe 'JavaScript'
|
||||
|
||||
describe ".replaceSelectedText()", ->
|
||||
it "doesn't call the replace function when the selection is empty", ->
|
||||
replaced = false
|
||||
edited = false
|
||||
replacer = (text) ->
|
||||
replaced = true
|
||||
'new'
|
||||
|
||||
editor.moveCursorToTop()
|
||||
edited = editor.replaceSelectedText(replacer)
|
||||
expect(replaced).toBe false
|
||||
expect(edited).toBe false
|
||||
|
||||
it "returns true when transformed text is non-empty", ->
|
||||
replaced = false
|
||||
edited = false
|
||||
replacer = (text) ->
|
||||
replaced = true
|
||||
'new'
|
||||
|
||||
editor.moveCursorToTop()
|
||||
editor.selectToEndOfLine()
|
||||
edited = editor.replaceSelectedText(replacer)
|
||||
expect(replaced).toBe true
|
||||
expect(edited).toBe true
|
||||
|
||||
it "returns false when transformed text is null", ->
|
||||
replaced = false
|
||||
edited = false
|
||||
replacer = (text) ->
|
||||
replaced = true
|
||||
null
|
||||
|
||||
editor.moveCursorToTop()
|
||||
editor.selectToEndOfLine()
|
||||
edited = editor.replaceSelectedText(replacer)
|
||||
expect(replaced).toBe true
|
||||
expect(edited).toBe false
|
||||
|
||||
it "returns false when transformed text is undefined", ->
|
||||
replaced = false
|
||||
edited = false
|
||||
replacer = (text) ->
|
||||
replaced = true
|
||||
undefined
|
||||
|
||||
editor.moveCursorToTop()
|
||||
editor.selectToEndOfLine()
|
||||
edited = editor.replaceSelectedText(replacer)
|
||||
expect(replaced).toBe true
|
||||
expect(edited).toBe false
|
||||
|
||||
@@ -710,3 +710,59 @@ describe "RootView", ->
|
||||
|
||||
lowerRightEditor = rightEditor.splitDown()
|
||||
expect(lowerRightEditor.find(".line:first").text()).toBe " "
|
||||
|
||||
describe ".eachEditor(callback)", ->
|
||||
beforeEach ->
|
||||
rootView.attachToDom()
|
||||
|
||||
it "invokes the callback for existing editor", ->
|
||||
count = 0
|
||||
callbackEditor = null
|
||||
callback = (editor) ->
|
||||
callbackEditor = editor
|
||||
count++
|
||||
rootView.eachEditor(callback)
|
||||
expect(count).toBe 1
|
||||
expect(callbackEditor).toBe rootView.getActiveEditor()
|
||||
|
||||
it "invokes the callback for new editor", ->
|
||||
count = 0
|
||||
callbackEditor = null
|
||||
callback = (editor) ->
|
||||
callbackEditor = editor
|
||||
count++
|
||||
|
||||
rootView.eachEditor(callback)
|
||||
count = 0
|
||||
callbackEditor = null
|
||||
rootView.getActiveEditor().splitRight()
|
||||
expect(count).toBe 1
|
||||
expect(callbackEditor).toBe rootView.getActiveEditor()
|
||||
|
||||
describe ".eachBuffer(callback)", ->
|
||||
beforeEach ->
|
||||
rootView.attachToDom()
|
||||
|
||||
it "invokes the callback for existing buffer", ->
|
||||
count = 0
|
||||
callbackBuffer = null
|
||||
callback = (buffer) ->
|
||||
callbackBuffer = buffer
|
||||
count++
|
||||
rootView.eachBuffer(callback)
|
||||
expect(count).toBe 1
|
||||
expect(callbackBuffer).toBe rootView.getActiveEditor().getBuffer()
|
||||
|
||||
it "invokes the callback for new buffer", ->
|
||||
count = 0
|
||||
callbackBuffer = null
|
||||
callback = (buffer) ->
|
||||
callbackBuffer = buffer
|
||||
count++
|
||||
|
||||
rootView.eachBuffer(callback)
|
||||
count = 0
|
||||
callbackBuffer = null
|
||||
rootView.open(require.resolve('fixtures/sample.txt'))
|
||||
expect(count).toBe 1
|
||||
expect(callbackBuffer).toBe rootView.getActiveEditor().getBuffer()
|
||||
|
||||
Reference in New Issue
Block a user