mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Move saveAll and specs to PaneContainer
And simplify the specs… we don't *really* need to save. We can just ensure that save is called on everything.
This commit is contained in:
committed by
probablycorey
parent
e4bf73b41c
commit
7ebce683c6
@@ -13,6 +13,8 @@ describe "PaneContainer", ->
|
||||
@content: -> @div tabindex: -1
|
||||
initialize: (@myText) -> @text(@myText)
|
||||
serialize: -> deserializer: 'TestView', myText: @myText
|
||||
getPath: -> "/tmp/hi"
|
||||
save: -> @saved = true
|
||||
|
||||
container = new PaneContainer
|
||||
pane1 = new Pane(new TestView('1'))
|
||||
@@ -72,6 +74,16 @@ describe "PaneContainer", ->
|
||||
pane4.splitDown()
|
||||
expect(panes).toEqual []
|
||||
|
||||
describe ".saveAll()", ->
|
||||
it "saves all open pane items", ->
|
||||
pane1.showItem(new TestView('4'))
|
||||
|
||||
container.saveAll()
|
||||
|
||||
for pane in container.getPanes()
|
||||
for item in pane.getItems()
|
||||
expect(item.saved).toBeTruthy()
|
||||
|
||||
describe "serialization", ->
|
||||
it "can be serialized and deserialized, and correctly adjusts dimensions of deserialized panes after attach", ->
|
||||
newContainer = deserialize(container.serialize())
|
||||
|
||||
@@ -279,36 +279,6 @@ describe "RootView", ->
|
||||
editSession = rootView.open('b', changeFocus: false)
|
||||
expect(activePane.focus).not.toHaveBeenCalled()
|
||||
|
||||
describe ".saveAll()", ->
|
||||
it "saves all open editors", ->
|
||||
project.setPath('/tmp')
|
||||
file1 = '/tmp/atom-temp1.txt'
|
||||
file2 = '/tmp/atom-temp2.txt'
|
||||
fs.write(file1, "file1")
|
||||
fs.write(file2, "file2")
|
||||
rootView.open(file1)
|
||||
|
||||
editor1 = rootView.getActiveView()
|
||||
buffer1 = editor1.activeEditSession.buffer
|
||||
expect(buffer1.getText()).toBe("file1")
|
||||
expect(buffer1.isModified()).toBe(false)
|
||||
buffer1.setText('edited1')
|
||||
expect(buffer1.isModified()).toBe(true)
|
||||
|
||||
editor2 = editor1.splitRight(project.buildEditSession('atom-temp2.txt'))
|
||||
buffer2 = editor2.activeEditSession.buffer
|
||||
expect(buffer2.getText()).toBe("file2")
|
||||
expect(buffer2.isModified()).toBe(false)
|
||||
buffer2.setText('edited2')
|
||||
expect(buffer2.isModified()).toBe(true)
|
||||
|
||||
rootView.saveAll()
|
||||
|
||||
expect(buffer1.isModified()).toBe(false)
|
||||
expect(fs.read(buffer1.getPath())).toBe("edited1")
|
||||
expect(buffer2.isModified()).toBe(false)
|
||||
expect(fs.read(buffer2.getPath())).toBe("edited2")
|
||||
|
||||
describe "window:toggle-invisibles event", ->
|
||||
it "shows/hides invisibles in all open and future editors", ->
|
||||
rootView.height(200)
|
||||
|
||||
@@ -36,6 +36,9 @@ class PaneContainer extends View
|
||||
getRoot: ->
|
||||
@children().first().view()
|
||||
|
||||
saveAll: ->
|
||||
pane.saveItems() for pane in @getPanes()
|
||||
|
||||
getPanes: ->
|
||||
@find('.pane').views()
|
||||
|
||||
|
||||
@@ -148,7 +148,7 @@ class RootView extends View
|
||||
super
|
||||
|
||||
saveAll: ->
|
||||
pane.saveItems() for pane in @getPanes()
|
||||
@panes.saveAll()
|
||||
|
||||
eachPane: (callback) ->
|
||||
@panes.eachPane(callback)
|
||||
|
||||
Reference in New Issue
Block a user