From 511d621593a7c157f9f08994da1485a518f95796 Mon Sep 17 00:00:00 2001 From: Felix Hammerl Date: Wed, 3 Feb 2016 18:48:13 +0100 Subject: Issue #552 - Add upload abort Cancels an upload and restores the user interface to ready-for-upload state --- web-ui/test/spec/mail_view/ui/attachment_icon.spec.js | 18 ++++++++++++++++++ web-ui/test/spec/mail_view/ui/attachment_list.spec.js | 17 ++++++++++++++++- 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'web-ui/test/spec') 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('
' + '' + - '' + + '' + '
'); }); @@ -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(); -- cgit v1.2.3