diff --git a/spec/atom/root-view-spec.coffee b/spec/atom/root-view-spec.coffee index 8c32a604a..1aae9bbb6 100644 --- a/spec/atom/root-view-spec.coffee +++ b/spec/atom/root-view-spec.coffee @@ -6,6 +6,21 @@ describe "RootView", -> rootView = null beforeEach -> rootView = RootView.build() + describe "initialize", -> + describe "when called with a url", -> + it "opens the given url in the editor", -> + url = require.resolve 'fixtures/sample.txt' + rootView = RootView.build {url} + + expect(rootView.editor.buffer.url).toBe url + + describe "when not called with a url", -> + it "opens an empty buffer", -> + url = null + rootView = RootView.build {url} + + expect(rootView.editor.buffer.url).toBeNull() + describe ".addPane(view)", -> it "adds the given view to the rootView (at the bottom by default)", -> expect(rootView.vertical.children().length).toBe 1 diff --git a/src/atom/root-view.coffee b/src/atom/root-view.coffee index ba6581388..c03d44314 100644 --- a/src/atom/root-view.coffee +++ b/src/atom/root-view.coffee @@ -7,11 +7,6 @@ Template = require 'template' module.exports = class RootView extends Template - @attach: -> - view = @build() - $('body').append view - view - content: -> @link rel: 'stylesheet', href: "#{require.resolve('atom.css')}?#{(new Date).getTime()}" @div id: 'app-horizontal', => @@ -20,11 +15,13 @@ class RootView extends Template @subview 'editor', Editor.build() viewProperties: - initialize: -> + initialize: ({url}) -> @bindKey 'meta+s', => @editor.save() @bindKey 'meta+w', => window.close() @bindKey 'meta+t', => @toggleFileFinder() + @editor.open url + addPane: (view) -> pane = $('
') pane.append(view) diff --git a/src/atom/window.coffee b/src/atom/window.coffee index 3c194715b..9e4777e90 100644 --- a/src/atom/window.coffee +++ b/src/atom/window.coffee @@ -13,8 +13,8 @@ windowAdditions = startup: -> @menuItemActions = {} - @rootView = RootView.attach() - @rootView.editor.open $atomController.url?.toString() + @rootView = RootView.build(url: $atomController.url?.toString()) + $('body').append @rootView @registerEventHandlers() @bindMenuItems() $(window).focus()