diff --git a/spec/app/window-spec.coffee b/spec/app/window-spec.coffee index 316f480c8..2471d6cc3 100644 --- a/spec/app/window-spec.coffee +++ b/spec/app/window-spec.coffee @@ -2,8 +2,11 @@ $ = require 'jquery' fs = require 'fs' describe "Window", -> + [rootView] = [] + beforeEach -> window.attachRootView(require.resolve('fixtures')) + rootView = window.rootView afterEach -> window.shutdown() @@ -68,7 +71,7 @@ describe "Window", -> expect(atom.getRootViewStateForPath(window.rootView.project.getPath())).toBeUndefined() expectedState = JSON.parse(JSON.stringify(window.rootView.serialize())) # JSON.stringify removes keys with undefined values $(window).trigger 'beforeunload' - expect(atom.getRootViewStateForPath(window.rootView.project.getPath())).toEqual expectedState + expect(atom.getRootViewStateForPath(rootView.project.getPath())).toEqual expectedState it "unsubscribes from all buffers", -> rootView.open('sample.js') @@ -79,3 +82,12 @@ describe "Window", -> $(window).trigger 'beforeunload' expect(editor1.getBuffer().subscriptionCount()).toBe 0 + + describe ".shutdown()", -> + it "only deactivates the RootView the first time it is called", -> + deactivateSpy = spyOn(rootView, "deactivate").andCallThrough() + window.shutdown() + expect(rootView.deactivate).toHaveBeenCalled() + deactivateSpy.reset() + window.shutdown() + expect(rootView.deactivate).not.toHaveBeenCalled() diff --git a/src/app/window.coffee b/src/app/window.coffee index 23e4dbb36..85077e84a 100644 --- a/src/app/window.coffee +++ b/src/app/window.coffee @@ -47,7 +47,8 @@ windowAdditions = false shutdown: -> - @rootView.deactivate() + @rootView?.deactivate() + @rootView = null $(window).unbind('focus') $(window).unbind('blur') $(window).off('before')