summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/mail_view/ui/feedback_box.spec.js
blob: 4702672c1df50e6ebcdbeeb9be8ec79d1a882fc5 (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
describeComponent('mail_view/ui/feedback_box', function () {
  'use strict';
  beforeEach(function () {
    Pixelated.mockBloodhound();
    this.setupComponent('<div></div>');
  });


  describe('close button behavior', function() {

    it('should fire Show no message selected if the close button is clicked', function() {
      var spy = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openNoMessageSelected);
      this.component.select('closeButton').click();
      expect(spy).toHaveBeenTriggeredOn(document);
    });

  });

  describe('when submit feedback', function () {

    it('should fire submit feedback event', function () {
      var spy = spyOnEvent(document, Pixelated.events.feedback.submit);

      this.component.select('textBox').val('Pixelated is Awesome!');
      this.component.select('submitButton').click();
      expect(spy).toHaveBeenTriggeredOnAndWith(document, {feedback: 'Pixelated is Awesome!'});
    });

    it('should close feedback box after submit', function() {
      var spy = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openNoMessageSelected);

      this.component.trigger(document, Pixelated.events.feedback.submitted);
      expect(spy).toHaveBeenTriggeredOn(document);
    });

    it('should shows success message after submit', function () {
      var spy = spyOnEvent(document, Pixelated.events.ui.userAlerts.displayMessage);

      this.component.trigger(document, Pixelated.events.feedback.submitted);
      expect(spy).toHaveBeenTriggeredOnAndWith(document, {message: 'Thanks for your feedback!'});
    });

  });

});