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

  describe('attachment', function () {
    beforeEach(function () {
        Pixelated.mockBloodhound();
        this.setupComponent();
    });

    it('should render attachment button if feature enabled', function () {
        expect(this.$node.html()).toMatch('<i class="fa fa-paperclip"></i>');
    });

    it('should be busy', function() {
        this.component.uploadInProgress();

        expect(this.component.attr.busy).toBe(true);
    });

    it('should not be busy', function() {
        this.component.uploadFinished();

        expect(this.component.attr.busy).toBe(false);
    });

    it('should trigger start of attachment upload process', function () {
        var triggerUploadAttachment = spyOnEvent(document, Pixelated.events.mail.startUploadAttachment);

        this.$node.click();

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

    it('should not trigger attachment upload when busy', function () {
        this.component.uploadInProgress();
        var triggerUploadAttachment = spyOnEvent(document, Pixelated.events.mail.startUploadAttachment);

        this.$node.click();

        expect(triggerUploadAttachment).not.toHaveBeenTriggeredOn(document);
    });

  });
});