init.spec.js 998 B

123456789101112131415161718192021222324252627282930313233343536
  1. /* global expect, it, describe, Snowflake, UI */
  2. // Fake snowflake to interact with
  3. var snowflake = {
  4. ui: new UI,
  5. broker: {
  6. sendAnswer: function() {}
  7. },
  8. state: Snowflake.MODE.INIT
  9. };
  10. describe('Init', function() {
  11. it('gives a dialog when closing, only while active', function() {
  12. silenceNotifications = false;
  13. snowflake.state = Snowflake.MODE.WEBRTC_READY;
  14. var msg = window.onbeforeunload();
  15. expect(snowflake.state).toBe(Snowflake.MODE.WEBRTC_READY);
  16. expect(msg).toBe(Snowflake.MESSAGE.CONFIRMATION);
  17. snowflake.state = Snowflake.MODE.INIT;
  18. msg = window.onbeforeunload();
  19. expect(snowflake.state).toBe(Snowflake.MODE.INIT);
  20. expect(msg).toBe(null);
  21. });
  22. it('does not give a dialog when silent flag is on', function() {
  23. silenceNotifications = true;
  24. snowflake.state = Snowflake.MODE.WEBRTC_READY;
  25. var msg = window.onbeforeunload();
  26. expect(snowflake.state).toBe(Snowflake.MODE.WEBRTC_READY);
  27. expect(msg).toBe(null);
  28. });
  29. });