summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/mail_view/ui/mail_actions.spec.js
blob: 93db01935a8e718a248f5e7dbc0586fbb31b677f (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
/*global Smail */

describeComponent('mail_view/ui/mail_actions', function () {
  'use strict';

  var testData;

  beforeEach(function(){
    testData = Smail.testData();
    setupComponent(testData);
  });

  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, Smail.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, Smail.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, Smail.events.ui.mail.delete);

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

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

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

});