From 7ebce683c651c0b437e1b3e0d4367361ab9dc0c8 Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Fri, 1 Mar 2013 16:44:27 -0700 Subject: [PATCH] Move saveAll and specs to PaneContainer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit And simplify the specs… we don't *really* need to save. We can just ensure that save is called on everything. --- spec/app/pane-container-spec.coffee | 12 ++++++++++++ spec/app/root-view-spec.coffee | 30 ----------------------------- src/app/pane-container.coffee | 3 +++ src/app/root-view.coffee | 2 +- 4 files changed, 16 insertions(+), 31 deletions(-) diff --git a/spec/app/pane-container-spec.coffee b/spec/app/pane-container-spec.coffee index 063d3598b..6c1d8179a 100644 --- a/spec/app/pane-container-spec.coffee +++ b/spec/app/pane-container-spec.coffee @@ -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()) diff --git a/spec/app/root-view-spec.coffee b/spec/app/root-view-spec.coffee index 25cb21e6d..6604f7521 100644 --- a/spec/app/root-view-spec.coffee +++ b/spec/app/root-view-spec.coffee @@ -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) diff --git a/src/app/pane-container.coffee b/src/app/pane-container.coffee index 12c88cc09..423ebab29 100644 --- a/src/app/pane-container.coffee +++ b/src/app/pane-container.coffee @@ -36,6 +36,9 @@ class PaneContainer extends View getRoot: -> @children().first().view() + saveAll: -> + pane.saveItems() for pane in @getPanes() + getPanes: -> @find('.pane').views() diff --git a/src/app/root-view.coffee b/src/app/root-view.coffee index 0246861d9..0ce0b04ba 100644 --- a/src/app/root-view.coffee +++ b/src/app/root-view.coffee @@ -148,7 +148,7 @@ class RootView extends View super saveAll: -> - pane.saveItems() for pane in @getPanes() + @panes.saveAll() eachPane: (callback) -> @panes.eachPane(callback)