snowflake/proxy/spec/init.spec.coffee
2019-05-16 12:07:06 -04:00

28 lines
845 B
CoffeeScript

# Fake snowflake to interact with
snowflake =
ui: new UI
broker:
sendAnswer: ->
state: Snowflake.MODE.INIT
describe 'Init', ->
it 'gives a dialog when closing, only while active', ->
silenceNotifications = false
snowflake.state = Snowflake.MODE.WEBRTC_READY
msg = window.onbeforeunload()
expect(snowflake.state).toBe Snowflake.MODE.WEBRTC_READY
expect(msg).toBe Snowflake.MESSAGE.CONFIRMATION
snowflake.state = Snowflake.MODE.INIT
msg = window.onbeforeunload()
expect(snowflake.state).toBe Snowflake.MODE.INIT
expect(msg).toBe null
it 'does not give a dialog when silent flag is on', ->
silenceNotifications = true
snowflake.state = Snowflake.MODE.WEBRTC_READY
msg = window.onbeforeunload()
expect(snowflake.state).toBe Snowflake.MODE.WEBRTC_READY
expect(msg).toBe null