summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/mail_list_actions/ui/mail_list_actions.spec.js
blob: 1ab90562ac7c059e6966a81f85479ccf17daa190 (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
describeComponent('mail_list_actions/ui/mail_list_actions', function () {
  'use strict';
  var mailListActionsContainer;
  var i18n;
  describe('post initialization', function () {
    beforeEach(function () {
      this.setupComponent();
      i18n = require('views/i18n');
      mailListActionsContainer = $('<input>', { id: 'delete-selected'});
    });

    it('should render button text', function () {
      $(document).trigger(Pixelated.events.ui.tag.select, {tag: 'inbox'});

      expect(this.component.$node.html()).toMatch('<li><input type="button" id="delete-selected" value="' + i18n.t('Delete') + '" disabled="disabled"></li>');
    });

    it('should render button text delete permanently if tag trash', function () {
      $(document).trigger(Pixelated.events.ui.tag.select, {tag: 'trash'});
      expect(this.component.$node.html()).toMatch('<li><input type="button" id="delete-selected" value="Delete permanently" disabled="disabled"></li>');
    });

    it('should render button delete permanently if url contains trash tag', function () {
      var urlParams = require('page/router/url_params');
      spyOn(urlParams, 'getTag').and.returnValue('trash');

      this.setupComponent();

      expect(this.component.$node.html()).toMatch('<li><input type="button" id="delete-selected" value="Delete Permanently" disabled="disabled"></li>');
    });

    it('should render move to inbox if on trash', function () {
      var urlParams = require('page/router/url_params');
      spyOn(urlParams, 'getTag').and.returnValue('trash');

      this.setupComponent();

      expect(this.component.$node.html()).toMatch('<li><input type="button" id="recover-selected" value="Move to Inbox" disabled="disabled"></li>');
    });

    it('should not render move to inbox if on trash', function () {
      var urlParams = require('page/router/url_params');
      spyOn(urlParams, 'getTag').and.returnValue('inbox');

      this.setupComponent();

      expect(this.component.$node.html()).not.toMatch('<li><input type="button" id="recover-selected" value="Move to Inbox" disabled="disabled"></li>');
    });
  });
});