Spy on AtomEnvironment.destroy in window event handler spec

This commit is contained in:
Max Brunsfeld
2016-09-20 17:45:58 -07:00
parent d1a4fd2378
commit 890436a456

View File

@@ -53,6 +53,7 @@ describe "WindowEventHandler", ->
describe "beforeunload event", ->
beforeEach ->
jasmine.unspy(TextEditor.prototype, "shouldPromptToSave")
spyOn(atom, 'destroy')
spyOn(ipcRenderer, 'send')
describe "when pane items are modified", ->
@@ -66,12 +67,14 @@ describe "WindowEventHandler", ->
window.dispatchEvent(new CustomEvent('beforeunload'))
expect(atom.workspace.confirmClose).toHaveBeenCalled()
expect(ipcRenderer.send).not.toHaveBeenCalledWith('did-cancel-window-unload')
expect(atom.destroy).toHaveBeenCalled()
it "cancels the unload if the user selects cancel", ->
spyOn(atom.workspace, 'confirmClose').andReturn(false)
window.dispatchEvent(new CustomEvent('beforeunload'))
expect(atom.workspace.confirmClose).toHaveBeenCalled()
expect(ipcRenderer.send).toHaveBeenCalledWith('did-cancel-window-unload')
expect(atom.destroy).not.toHaveBeenCalled()
describe "when a link is clicked", ->
it "opens the http/https links in an external application", ->