mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-14 05:11:19 -04:00
Some files were omitted in the .eslintignore, left as an exercise to the reader. We probably want to reduce amount of globals overall and use proper es modules.
35 lines
998 B
JavaScript
35 lines
998 B
JavaScript
/* global expect, it, describe, Snowflake, UI */
|
|
|
|
// Fake snowflake to interact with
|
|
|
|
var snowflake = {
|
|
ui: new UI,
|
|
broker: {
|
|
sendAnswer: function() {}
|
|
},
|
|
state: Snowflake.MODE.INIT
|
|
};
|
|
|
|
describe('Init', function() {
|
|
|
|
it('gives a dialog when closing, only while active', function() {
|
|
silenceNotifications = false;
|
|
snowflake.state = Snowflake.MODE.WEBRTC_READY;
|
|
var 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', function() {
|
|
silenceNotifications = true;
|
|
snowflake.state = Snowflake.MODE.WEBRTC_READY;
|
|
var msg = window.onbeforeunload();
|
|
expect(snowflake.state).toBe(Snowflake.MODE.WEBRTC_READY);
|
|
expect(msg).toBe(null);
|
|
});
|
|
|
|
});
|