confirmation dialog on proxy close (close #23)

This commit is contained in:
Serene Han 2016-03-02 05:45:27 -08:00
parent 8a8273e972
commit d2e61e315c
2 changed files with 21 additions and 0 deletions

View file

@ -23,6 +23,7 @@ snowflake =
ui: fakeUI
broker:
sendAnswer: ->
state: MODE.INIT
describe 'Snowflake', ->
@ -58,3 +59,14 @@ describe 'Snowflake', ->
s = new Snowflake(new FakeBroker(), fakeUI)
s.makeProxyPair()
expect(s.proxyPairs.length).toBe 2
it 'gives a dialog when closing, only while active', ->
snowflake.state = MODE.WEBRTC_READY
msg = window.onbeforeunload()
expect(snowflake.state).toBe MODE.WEBRTC_READY
expect(msg).toBe CONFIRMATION_MESSAGE
snowflake.state = MODE.INIT
msg = window.onbeforeunload()
expect(snowflake.state).toBe MODE.INIT
expect(msg).toBe null