mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-11-10 10:17:11 +03:00
Trigger complete beforeunload event
jquery 2.0 fails to trigger this event using just $(window).trigger('beforeunload')
This commit is contained in:
parent
607ed972c1
commit
ee6b2b0776
@ -52,13 +52,18 @@ describe "Window", ->
|
||||
expect(beforeunload).toHaveBeenCalled()
|
||||
|
||||
describe "beforeunload event", ->
|
||||
[beforeUnloadEvent] = []
|
||||
|
||||
beforeEach ->
|
||||
beforeUnloadEvent = $.Event(new Event('beforeunload'))
|
||||
|
||||
describe "when pane items are are modified", ->
|
||||
it "prompts user to save and and calls rootView.confirmClose", ->
|
||||
spyOn(rootView, 'confirmClose').andCallThrough()
|
||||
spyOn(atom, "confirmSync").andReturn(2)
|
||||
editSession = rootView.openSync("sample.js")
|
||||
editSession.insertText("I look different, I feel different.")
|
||||
$(window).trigger 'beforeunload'
|
||||
$(window).trigger(beforeUnloadEvent)
|
||||
expect(rootView.confirmClose).toHaveBeenCalled()
|
||||
expect(atom.confirmSync).toHaveBeenCalled()
|
||||
|
||||
@ -66,14 +71,14 @@ describe "Window", ->
|
||||
spyOn(atom, "confirmSync").andReturn(2)
|
||||
editSession = rootView.openSync("sample.js")
|
||||
editSession.insertText("I look different, I feel different.")
|
||||
expect(window.onbeforeunload(new Event('beforeunload'))).toBeTruthy()
|
||||
$(window).trigger(beforeUnloadEvent)
|
||||
expect(atom.confirmSync).toHaveBeenCalled()
|
||||
|
||||
it "prompts user to save and handler returns false if dialog is canceled", ->
|
||||
spyOn(atom, "confirmSync").andReturn(1)
|
||||
editSession = rootView.openSync("sample.js")
|
||||
editSession.insertText("I look different, I feel different.")
|
||||
expect(window.onbeforeunload(new Event('beforeunload'))).toBeFalsy()
|
||||
$(window).trigger(beforeUnloadEvent)
|
||||
expect(atom.confirmSync).toHaveBeenCalled()
|
||||
|
||||
describe ".unloadEditorWindow()", ->
|
||||
|
Loading…
Reference in New Issue
Block a user