diff options
author | Felix Hammerl <fhammerl@thoughtworks.com> | 2016-02-03 18:48:13 +0100 |
---|---|---|
committer | Felix Hammerl <fhammerl@thoughtworks.com> | 2016-02-03 18:54:33 +0100 |
commit | 511d621593a7c157f9f08994da1485a518f95796 (patch) | |
tree | ea31b5c4d7d6de265c79a8cb60d054734ed2bc24 /web-ui/test/spec/mail_view/ui | |
parent | 761f429873cb453f244eaf4cad7848e78f9f78c9 (diff) |
Issue #552 - Add upload abort
Cancels an upload and restores the user interface to ready-for-upload state
Diffstat (limited to 'web-ui/test/spec/mail_view/ui')
-rw-r--r-- | web-ui/test/spec/mail_view/ui/attachment_icon.spec.js | 18 | ||||
-rw-r--r-- | web-ui/test/spec/mail_view/ui/attachment_list.spec.js | 17 |
2 files changed, 34 insertions, 1 deletions
diff --git a/web-ui/test/spec/mail_view/ui/attachment_icon.spec.js b/web-ui/test/spec/mail_view/ui/attachment_icon.spec.js index 1b2f182e..86ef420b 100644 --- a/web-ui/test/spec/mail_view/ui/attachment_icon.spec.js +++ b/web-ui/test/spec/mail_view/ui/attachment_icon.spec.js @@ -17,12 +17,30 @@ describeComponent('mail_view/ui/attachment_icon', function () { expect(this.component.attr.busy).toBe(true); }); + it('should be busy after upload event', function() { + $(document).trigger(Pixelated.events.mail.uploadingAttachment); + + 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 not be busy after upload finished event', function() { + $(document).trigger(Pixelated.events.mail.uploadedAttachment); + + expect(this.component.attr.busy).toBe(false); + }); + + it('should not be busy after upload failed event', function() { + $(document).trigger(Pixelated.events.mail.failedUploadAttachment); + + expect(this.component.attr.busy).toBe(false); + }); + it('should trigger start of attachment upload process', function () { var triggerUploadAttachment = spyOnEvent(document, Pixelated.events.mail.startUploadAttachment); diff --git a/web-ui/test/spec/mail_view/ui/attachment_list.spec.js b/web-ui/test/spec/mail_view/ui/attachment_list.spec.js index 1b351d36..79f4b81e 100644 --- a/web-ui/test/spec/mail_view/ui/attachment_list.spec.js +++ b/web-ui/test/spec/mail_view/ui/attachment_list.spec.js @@ -5,7 +5,7 @@ describeMixin('mail_view/ui/attachment_list', function () { beforeEach(function () { this.setupComponent('<div id="attachment-list">' + '<ul id="attachment-list-item"></ul>' + - '<ul id="attachment-upload-item"><li><a>Uploading...</a><div id="attachment-upload-item-progress" class="progress"><div class="progress-bar progress-bar-success"></div></div></li></ul>' + + '<ul id="attachment-upload-item"><li><div id="attachment-upload-item-progress" class="progress"><div class="progress-bar progress-bar-success"></div></div><a>Uploading... <i id="attachment-upload-item-abort" class="fa fa-close remove-icon"></i></a></li></ul>' + '</div>'); }); @@ -57,6 +57,21 @@ describeMixin('mail_view/ui/attachment_list', function () { }); }); + describe('Cancel', function() { + it('should cancel the upload', function() { + var fakeJQXHR = { + abort: function() {} + }; + spyOn(fakeJQXHR, 'abort'); + // this.component.showUploadProgressBar(); + this.component.attachUploadAbort(null, fakeJQXHR); + + this.component.select('attachmentUploadItemAbort').click(); + + expect(fakeJQXHR.abort).toHaveBeenCalled(); + }); + }); + describe('Error', function() { it('should show error message', function () { this.component.showUploadError(); |