summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/mail_view/ui/draft_button.spec.js
blob: e1e968de195ed9ae072100441a61f28594311a19 (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
/* global Pixelated */

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

  describe('draft save button', function(){
    beforeEach(function(){
      this.setupComponent('<button></button>');
    });

    describe('after initialize', function(){
      it('should be enabled', function(){
        expect(this.$node).toBeDisabled();
      });
    });

    describe('when enabled', function(){
      beforeEach(function(){
        this.$node.prop('disabled', false);
      });

      it('should be disabled when saving draft message', function(){
        $(document).trigger(Pixelated.events.mail.saveDraft, {});
        expect(this.$node).toBeDisabled();
      });
    });

    describe('when disabled', function(){
      beforeEach(function(){
        this.$node.prop('disabled', true);
      });

      it('should be enabled when draft message has been saved', function(){
        $(document).trigger(Pixelated.events.mail.draftSaved, {});
        expect(this.$node).not.toBeDisabled();
      });
    });

  });
});