From ec3a7f46f16c32bbaf22a14a92a890e1ab900e94 Mon Sep 17 00:00:00 2001 From: NavaL Date: Tue, 22 Dec 2015 18:58:57 +0100 Subject: front-end for sending attachments Issue #548 --- .../spec/mail_view/data/attachment_list.spec.js | 21 +++++++++++++++++++ .../test/spec/mail_view/data/mail_builder.spec.js | 8 ++++++++ web-ui/test/spec/mail_view/ui/attachment.spec.js | 24 +++++++++++++++++++--- 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100644 web-ui/test/spec/mail_view/data/attachment_list.spec.js (limited to 'web-ui/test') diff --git a/web-ui/test/spec/mail_view/data/attachment_list.spec.js b/web-ui/test/spec/mail_view/data/attachment_list.spec.js new file mode 100644 index 00000000..74c1dea7 --- /dev/null +++ b/web-ui/test/spec/mail_view/data/attachment_list.spec.js @@ -0,0 +1,21 @@ +describeMixin('mail_view/data/attachment_list', function () { + 'use strict'; + + describe('initialization', function() { + beforeEach(function(){ + this.setupComponent(); + }); + + it('should add attachment to the list based on uploadedAttachment event', function () { + var stubAttachment = {attachment_id: 'faked'}; + $(document).trigger(Pixelated.events.mail.uploadedAttachment, stubAttachment); + expect(this.component.attr.attachments).toEqual([stubAttachment]); + + var anotherStubAttachment = {attachment_id: 'faked 2'}; + $(document).trigger(Pixelated.events.mail.uploadedAttachment, anotherStubAttachment); + expect(this.component.attr.attachments).toEqual([stubAttachment, anotherStubAttachment]); + }); + + }); + +}); diff --git a/web-ui/test/spec/mail_view/data/mail_builder.spec.js b/web-ui/test/spec/mail_view/data/mail_builder.spec.js index 7f69098f..7ba860f4 100644 --- a/web-ui/test/spec/mail_view/data/mail_builder.spec.js +++ b/web-ui/test/spec/mail_view/data/mail_builder.spec.js @@ -106,5 +106,13 @@ define(['mail_view/data/mail_builder'], function (mailBuilder) { expect(mail.tags).toContain('tag1'); }); + + it('sets attachments', function() { + var mail = mailBuilder.newMail() + .attachment(['faked attachment list']) + .build(); + + expect(mail.attachments).toEqual(['faked attachment list']); + }); }); }); diff --git a/web-ui/test/spec/mail_view/ui/attachment.spec.js b/web-ui/test/spec/mail_view/ui/attachment.spec.js index 5d14f860..bbea2f55 100644 --- a/web-ui/test/spec/mail_view/ui/attachment.spec.js +++ b/web-ui/test/spec/mail_view/ui/attachment.spec.js @@ -1,3 +1,21 @@ -/** - * Created by mnandri on 12/15/15. - */ +describeComponent('mail_view/ui/attachment', function () { + 'use strict'; + + describe('attachment', function () { + beforeEach(function () { + Pixelated.mockBloodhound(); + this.setupComponent(); + }); + + it('render attachment button if feature enabled', function () { + expect(this.$node.html()).toMatch(''); + }); + + xit('uploads attachment on click', function () { + var fileUploads = spyOn($, 'fileupload'); + this.$node.click(); + expect(fileUploads).toHaveBeenCalled(); + }); + + }); +}); -- cgit v1.2.3