summaryrefslogtreecommitdiff
path: root/web-ui/test
diff options
context:
space:
mode:
authorVictor Shyba <victor.shyba@gmail.com>2016-01-29 14:28:51 -0300
committerVictor Shyba <victor.shyba@gmail.com>2016-01-29 14:28:51 -0300
commite92c87f7500d0543cb95ab007046b9c91ba1a763 (patch)
tree2f8582a2c037eebcac677e9096196cad3c9c2edf /web-ui/test
parentd984d803936399caa393622171453566ff3194e0 (diff)
testing filesize validation, on attachments
Issue #550
Diffstat (limited to 'web-ui/test')
-rw-r--r--web-ui/test/spec/mail_view/ui/attachment_list.spec.js23
1 files changed, 23 insertions, 0 deletions
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 2308c227..9f14031e 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
@@ -39,6 +39,29 @@ describeMixin('mail_view/ui/attachment_list', function () {
expect(this.component.select('attachmentListItem').html()).toContain('(4.39 Kb');
});
+ it('should not upload files larger than 1MB', function () {
+ var submitFile = 'file not submitted', submitted = 'file submitted';
+ var mockSubmit = function (){ submitFile = submitted; };
+ var largeAttachment = {originalFiles: [{size: 4500000}], submit: mockSubmit};
+ spyOn(largeAttachment, 'submit');
+ var dummyEvent = 'whatever, not used';
+
+ this.component.checkAttachmentSize(dummyEvent, largeAttachment);
+
+ expect(largeAttachment.submit).not.toHaveBeenCalled();
+ });
+
+ it('should upload files smaller than 1MB', function () {
+ var submitFile = 'file not submitted', submitted = 'file submitted';
+ var mockSubmit = function (){ submitFile = submitted; };
+ var largeAttachment = {originalFiles: [{size: 450}], submit: mockSubmit};
+ var dummyEvent = 'whatever, not used';
+
+ this.component.checkAttachmentSize(dummyEvent, largeAttachment);
+
+ expect(submitFile).toEqual(submitted);
+ });
+
xit('should start uploading attachments', function () {
var stubAttachment = {ident: 'faked', name: 'haha.txt', size: 4500};
var mockAjax = spyOn($, 'ajax').and.callFake(function (params) {params.success(stubAttachment);});