summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/mixins/with_mail_sandbox.spec.js
blob: daa8cc396d61c88f6148e4cd9153de66dd76a355 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
describeMixin('mixins/with_mail_sandbox', function() {
  'use strict';

  beforeEach(function() {
    this.setupComponent('<iframe id="read-sandbox" sandbox="allow-popups allow-scripts" src scrolling="no"></iframe>');
    var iframe = document.querySelector('iframe');
    var template = ['',
      '<!DOCTYPE html>',
      '<html>',
      '<head>',
      '<meta charset="utf-8">',
      '<script>(function () {',
        '\'use strict\'',
        ';window.onmessage = function (e) {',
          'if (e.data.html) {',
            'var mainWindow = e.source;',
            'mainWindow.postMessage(\'data ok\', e.origin);',
          '}',
        '};',
      '})();',
    '</script>',
    '</head>',
    '<body>',
    '</body>',
    '</html>'].join('');
    iframe.src = URL.createObjectURL(new Blob([template], {type: "text/html"}));
  });

  it('should open reply container', function (done) {
    var showContainerEvent = spyOnEvent(document, Pixelated.events.ui.replyBox.showReplyContainer);
    this.component.showMailOnSandbox(Pixelated.testData().parsedMail.html);
    setTimeout(function() {
      expect(showContainerEvent).toHaveBeenTriggeredOn(document);
      done();
    }, 200);
  });

});