mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Add a mock-based test for Editor.prototype.split and ensure it doesn't raise exceptions when not in a pane
This commit is contained in:
@@ -2144,3 +2144,26 @@ describe "Editor", ->
|
||||
expect(editor.buffer.path).toBe "0"
|
||||
editor.loadPreviousEditSession()
|
||||
expect(editor.buffer.path).toBe "2"
|
||||
|
||||
describe "split methods", ->
|
||||
describe "when inside a pane", ->
|
||||
fakePane = null
|
||||
beforeEach ->
|
||||
fakePane = { splitUp: jasmine.createSpy('splitUp') }
|
||||
spyOn(editor, 'pane').andReturn(fakePane)
|
||||
|
||||
it "calls the corresponding split method on the containing pane with a copy of the editor", ->
|
||||
editor.splitUp()
|
||||
expect(fakePane.splitUp).toHaveBeenCalled()
|
||||
[editorCopy] = fakePane.splitUp.argsForCall[0]
|
||||
expect(editorCopy.serialize()).toEqual editor.serialize()
|
||||
expect(editorCopy).not.toBe editor
|
||||
|
||||
describe "when not inside a pane", ->
|
||||
it "does not split the editor, but doesn't throw an exception", ->
|
||||
editor.splitUp()
|
||||
editor.splitDown()
|
||||
editor.splitLeft()
|
||||
editor.splitRight()
|
||||
|
||||
|
||||
|
||||
@@ -494,16 +494,16 @@ class Editor extends View
|
||||
@setCursorBufferPosition(fold.start)
|
||||
|
||||
splitLeft: ->
|
||||
@pane().splitLeft(@copy())
|
||||
@pane()?.splitLeft(@copy())
|
||||
|
||||
splitRight: ->
|
||||
@pane().splitRight(@copy())
|
||||
@pane()?.splitRight(@copy())
|
||||
|
||||
splitUp: ->
|
||||
@pane().splitUp(@copy())
|
||||
@pane()?.splitUp(@copy())
|
||||
|
||||
splitDown: ->
|
||||
@pane().splitDown(@copy())
|
||||
@pane()?.splitDown(@copy())
|
||||
|
||||
pane: ->
|
||||
@parent('.pane').view()
|
||||
|
||||
Reference in New Issue
Block a user