summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/mail_view/ui/mail_actions.spec.js
blob: 580758a05dbe496f603cb4dfcb139cf0057ee892 (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
describeComponent('mail_view/ui/mail_actions', function () {
  'use strict';

  var testData;

  beforeEach(function(){
    testData = Pixelated.testData();
    this.setupComponent(testData.rawMail);
  });

  it('verifies if more actions list is hidden when rendering mail view', function() {

    var moreActionsComponent = this.component.select('moreActions');
    expect(moreActionsComponent.attr('style').trim()).toEqual('display: none;');

  });

  it('show more actions list when click on view more actions button', function(){

    this.component.select('viewMoreActions').click();

    var moreActionsComponent = this.component.select('moreActions');
    expect(moreActionsComponent.attr('style').trim()).not.toEqual('display: none;');
  });

  it('triggers a show reply box event when clicking on reply-button-top', function(){

    var showReplyBoxEvent = spyOnEvent(document, Pixelated.events.ui.replyBox.showReply);

    this.component.select('replyButtonTop').click();

    expect(showReplyBoxEvent).toHaveBeenTriggeredOn(document);
  });

  it('triggers a show reply all box event when clicking on reply-button-top and hide more actions list', function(){

    var showReplyAllEvent = spyOnEvent(document, Pixelated.events.ui.replyBox.showReplyAll);

    this.component.select('viewMoreActions').click();
    this.component.select('replyAllButtonTop').click();

    expect(showReplyAllEvent).toHaveBeenTriggeredOn(document);

    var moreActionsComponent = this.component.select('moreActions');
    expect(moreActionsComponent.attr('style').trim()).toEqual('display: none;');
  });

  it('triggers a delete event when clicking on delete-button-top', function(){
    var deleteEvent = spyOnEvent(document, Pixelated.events.ui.mail.delete);

    this.component.select('viewMoreActions').click();
    this.component.select('deleteButtonTop').click();

    expect(deleteEvent).toHaveBeenTriggeredOnAndWith(document, {mail: testData.rawMail.mail});

    var moreActionsComponent = this.component.select('moreActions');
    expect(moreActionsComponent.attr('style').trim()).toEqual('display: none;');
  });

});