summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/mail_view/ui/draft_button.spec.js
blob: de60750719ce32bc8ae78639b303590c1a15fe7e (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 disabled', 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();
      });
    });

  });
});