summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/page/pix_logo.spec.js
blob: 5d07a544c9c5abeeba529ee6ab62f82a92b85081 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
describeComponent('page/pix_logo', function () {
  'use strict';

  describe('pix logo', function () {
    it('should spin when loading another mail box', function () {
      this.setupComponent('<polygon id="clock1" class="logo-part-animation-off"></polygon>');
      var eventSpy = spyOnEvent(document, Pixelated.events.ui.page.spinLogo);
      $(document).trigger(Pixelated.events.ui.tag.select);

      expect(eventSpy).toHaveBeenTriggeredOn(document);
      expect(this.component.$node.hasClass('logo-part-animation-on')).toBe(true);
    });

    it('should stop spinning after mail box is loaded', function (done) {
      this.setupComponent('<polygon id="clock1" class="logo-part-animation-on"></polygon>');
      var eventSpy = spyOnEvent(document, Pixelated.events.ui.page.stopSpinningLogo);
      $(document).trigger(Pixelated.events.mails.available);

      var component = this.component;

      setTimeout(function() {
          expect(eventSpy).toHaveBeenTriggeredOn(document);
          expect(component.$node.hasClass('logo-part-animation-off')).toBe(true);
          done();
      }, 600);
    });

    it('should spin when saving draft', function () {
      this.setupComponent('<polygon id="clock1" class="logo-part-animation-off"></polygon>');
      var eventSpy = spyOnEvent(document, Pixelated.events.ui.page.spinLogo);
      $(document).trigger(Pixelated.events.mail.saveDraft);

      expect(eventSpy).toHaveBeenTriggeredOn(document);
      expect(this.component.$node.hasClass('logo-part-animation-on')).toBe(true);
    });

    it('should stop spinning after draft is saved', function (done) {
      this.setupComponent('<polygon id="clock1" class="logo-part-animation-on"></polygon>');
      var eventSpy = spyOnEvent(document, Pixelated.events.ui.page.stopSpinningLogo);
      $(document).trigger(Pixelated.events.mail.draftSaved);

      var component = this.component;

      setTimeout(function() {
          expect(eventSpy).toHaveBeenTriggeredOn(document);
          expect(component.$node.hasClass('logo-part-animation-off')).toBe(true);
          done();
      }, 600);
    });

    it('should spin when opening a mail message', function () {
      this.setupComponent('<polygon id="clock1" class="logo-part-animation-off"></polygon>');
      var eventSpy = spyOnEvent(document, Pixelated.events.ui.page.spinLogo);
      $(document).trigger(Pixelated.events.ui.mail.open);

      expect(eventSpy).toHaveBeenTriggeredOn(document);
      expect(this.component.$node.hasClass('logo-part-animation-on')).toBe(true);
    });

    it('should spin when opening a draft', function () {
      this.setupComponent('<polygon id="clock1" class="logo-part-animation-off"></polygon>');
      var eventSpy = spyOnEvent(document, Pixelated.events.ui.page.spinLogo);
      $(document).trigger(Pixelated.events.dispatchers.rightPane.openDraft);

      expect(eventSpy).toHaveBeenTriggeredOn(document);
      expect(this.component.$node.hasClass('logo-part-animation-on')).toBe(true);
    });

    it('should stop spinning after mail message is loaded', function (done) {
      this.setupComponent('<polygon id="clock1" class="logo-part-animation-on"></polygon>');
      var eventSpy = spyOnEvent(document, Pixelated.events.ui.page.stopSpinningLogo);
      $(document).trigger(Pixelated.events.mail.display);

      var component = this.component;

      setTimeout(function() {
          expect(eventSpy).toHaveBeenTriggeredOn(document);
          expect(component.$node.hasClass('logo-part-animation-off')).toBe(true);
          done();
      }, 600);
    });

    it('should spin when doing a search', function () {
      this.setupComponent('<polygon id="clock1" class="logo-part-animation-off"></polygon>');
      var eventSpy = spyOnEvent(document, Pixelated.events.ui.page.spinLogo);
      $(document).trigger(Pixelated.events.search.perform);

      expect(eventSpy).toHaveBeenTriggeredOn(document);
      expect(this.component.$node.hasClass('logo-part-animation-on')).toBe(true);
    });
  });
});