💚 Make sure to destroy AtomEnvironment in specs

This commit is contained in:
Antonio Scandurra 2015-10-13 15:30:45 +02:00
parent 1df90a220e
commit 6459891c89
3 changed files with 12 additions and 3 deletions

View File

@ -227,6 +227,8 @@ describe "AtomEnvironment", ->
expect(atomEnvironment.state.project).toEqual projectState
expect(atomEnvironment.saveStateSync).toHaveBeenCalled()
atomEnvironment.destroy()
describe "::destroy()", ->
it "unsubscribes from all buffers", ->
atomEnvironment = new AtomEnvironment(setRepresentedFilename: ->)

View File

@ -10,7 +10,7 @@ describe "WindowEventHandler", ->
[projectPath, windowEventHandler] = []
beforeEach ->
atom.windowEventHandler.unsubscribe()
atom.uninstallWindowEventHandler()
spyOn(atom, 'hide')
initialPath = atom.project.getPaths()[0]
spyOn(atom, 'getLoadSettings').andCallFake ->
@ -23,6 +23,7 @@ describe "WindowEventHandler", ->
afterEach ->
windowEventHandler.unsubscribe()
atom.installWindowEventHandler()
describe "when the window is loaded", ->
it "doesn't have .is-blurred on the body tag", ->

View File

@ -194,7 +194,7 @@ class AtomEnvironment extends Model
@registerDefaultViewProviders()
@installUncaughtErrorHandler()
@windowEventHandler = new WindowEventHandler(this)
@installWindowEventHandler()
setConfigSchema: ->
@config.setSchema null, {type: 'object', properties: _.clone(require('./config-schema'))}
@ -284,7 +284,7 @@ class AtomEnvironment extends Model
@project?.destroy()
@project = null
@windowEventHandler?.unsubscribe()
@uninstallWindowEventHandler()
###
Section: Event Subscription
@ -661,6 +661,12 @@ class AtomEnvironment extends Model
uninstallUncaughtErrorHandler: ->
window.onerror = @previousWindowErrorHandler
installWindowEventHandler: ->
@windowEventHandler = new WindowEventHandler(this)
uninstallWindowEventHandler: ->
@windowEventHandler?.unsubscribe()
###
Section: Messaging the User
###