2019-07-07 15:40:51 +02:00
|
|
|
/* global expect, it, describe, Snowflake, UI */
|
|
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
// Fake snowflake to interact with
|
|
|
|
|
|
2019-07-06 15:20:07 +02:00
|
|
|
var snowflake = {
|
2019-07-06 15:13:06 +02:00
|
|
|
ui: new UI,
|
|
|
|
|
broker: {
|
|
|
|
|
sendAnswer: function() {}
|
2019-10-18 15:10:03 -04:00
|
|
|
}
|
2019-07-06 15:13:06 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
describe('Init', function() {
|
2019-07-06 15:20:07 +02:00
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
it('gives a dialog when closing, only while active', function() {
|
|
|
|
|
silenceNotifications = false;
|
2019-10-18 15:10:03 -04:00
|
|
|
ui.setActive(true);
|
2019-07-06 15:20:07 +02:00
|
|
|
var msg = window.onbeforeunload();
|
2019-10-18 15:10:03 -04:00
|
|
|
expect(ui.active).toBe(true);
|
2019-07-06 15:13:06 +02:00
|
|
|
expect(msg).toBe(Snowflake.MESSAGE.CONFIRMATION);
|
2019-10-18 15:10:03 -04:00
|
|
|
ui.setActive(false);
|
2019-07-06 15:13:06 +02:00
|
|
|
msg = window.onbeforeunload();
|
2019-10-18 15:10:03 -04:00
|
|
|
expect(ui.active).toBe(false);
|
2019-07-06 15:20:07 +02:00
|
|
|
expect(msg).toBe(null);
|
2019-07-06 15:13:06 +02:00
|
|
|
});
|
2019-07-06 15:20:07 +02:00
|
|
|
|
|
|
|
|
it('does not give a dialog when silent flag is on', function() {
|
2019-07-06 15:13:06 +02:00
|
|
|
silenceNotifications = true;
|
2019-10-18 15:10:03 -04:00
|
|
|
ui.setActive(true);
|
2019-07-06 15:20:07 +02:00
|
|
|
var msg = window.onbeforeunload();
|
2019-10-18 15:10:03 -04:00
|
|
|
expect(ui.active).toBe(true);
|
2019-07-06 15:20:07 +02:00
|
|
|
expect(msg).toBe(null);
|
2019-07-06 15:13:06 +02:00
|
|
|
});
|
2019-07-06 15:20:07 +02:00
|
|
|
|
2019-07-06 15:13:06 +02:00
|
|
|
});
|