diff options
author | NavaL <mnandri@thoughtworks.com> | 2016-01-11 16:55:25 +0100 |
---|---|---|
committer | NavaL <mnandri@thoughtworks.com> | 2016-01-11 16:56:29 +0100 |
commit | 058d14143c179d9923eea433fc63094f4f9059aa (patch) | |
tree | cef20e046a64cb44ad0d882465411335cf049007 /web-ui/test/spec/mail_view | |
parent | 64106a5d6b589616db5ddd07f383b74c66e0b39d (diff) |
merging attachment_list ui and data, and making it into a mixin
Issue #573
Diffstat (limited to 'web-ui/test/spec/mail_view')
-rw-r--r-- | web-ui/test/spec/mail_view/data/attachment_list.spec.js | 35 | ||||
-rw-r--r-- | web-ui/test/spec/mail_view/ui/attachment_list.spec.js | 28 | ||||
-rw-r--r-- | web-ui/test/spec/mail_view/ui/draft_box.spec.js | 2 |
3 files changed, 15 insertions, 50 deletions
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 deleted file mode 100644 index 45167e33..00000000 --- a/web-ui/test/spec/mail_view/data/attachment_list.spec.js +++ /dev/null @@ -1,35 +0,0 @@ -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.appendAttachment, stubAttachment); - expect(this.component.attr.attachments).toEqual([stubAttachment]); - - var anotherStubAttachment = {attachment_id: 'faked 2'}; - $(document).trigger(Pixelated.events.mail.appendAttachment, anotherStubAttachment); - expect(this.component.attr.attachments).toEqual([stubAttachment, anotherStubAttachment]); - }); - - it('should reset attachment list on compose', function () { - this.component.attr.attachments = ['some array']; - $(document).trigger(Pixelated.events.mail.resetAttachments); - - expect(this.component.attr.attachments).toEqual([]); - }); - - it('should reset attachment list and tear down when email sent', function () { - this.component.attr.attachments = ['some array']; - $(document).trigger(Pixelated.events.mail.sent); - - expect(this.component.attr.attachments).toEqual([]); - }); - - }); - -}); 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 8bbc9f1a..ccede0d9 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 @@ -1,4 +1,4 @@ -describeComponent('mail_view/ui/attachment_list', function () { +describeMixin('mail_view/ui/attachment_list', function () { 'use strict'; describe('initialization', function () { @@ -8,9 +8,19 @@ describeComponent('mail_view/ui/attachment_list', function () { '</div>'); }); + it('should add attachment to the list based on uploadedAttachment event', function () { + var stubAttachment = {ident: 'faked'}; + $(document).trigger(Pixelated.events.mail.appendAttachment, stubAttachment); + expect(this.component.attr.attachments).toEqual([stubAttachment]); + + var anotherStubAttachment = {ident: 'faked 2'}; + $(document).trigger(Pixelated.events.mail.appendAttachment, anotherStubAttachment); + expect(this.component.attr.attachments).toEqual([stubAttachment, anotherStubAttachment]); + }); + it('should trigger add attachment event', function () { var triggerUploadAttachment = spyOnEvent(document, Pixelated.events.mail.appendAttachment); - var stubAttachment = {attachment_id: 'faked'}; + var stubAttachment = {ident: 'faked'}; $(document).trigger(Pixelated.events.mail.uploadedAttachment, stubAttachment); @@ -18,7 +28,7 @@ describeComponent('mail_view/ui/attachment_list', function () { }); it('should render attachment list view based on uploadedAttachment event', function () { - var stubAttachment = {attachment_id: 'faked', filename: 'haha.txt', filesize: 4500}; + var stubAttachment = {ident: 'faked', name: 'haha.txt', size: 4500, encoding: 'base64'}; $(document).trigger(Pixelated.events.mail.uploadedAttachment, stubAttachment); @@ -26,18 +36,8 @@ describeComponent('mail_view/ui/attachment_list', function () { expect(this.component.select('attachmentListItem').html()).toEqual(expected_li); }); - it('should tear down when email sent', function () { - var mockTearDown = spyOn(this.Component.prototype, 'resetAll'); - this.setupComponent('<div id="attachment-list">' + - '<ul id="attachment-list-item"></ul>' + - '</div>'); - $(document).trigger(Pixelated.events.mail.sent); - - expect(mockTearDown).toHaveBeenCalled(); - }); - xit('should start uploading attachments', function () { - var stubAttachment = {attachment_id: 'faked', filename: 'haha.txt', filesize: 4500}; + var stubAttachment = {ident: 'faked', name: 'haha.txt', size: 4500}; var mockAjax = spyOn($, 'ajax').and.callFake(function (params) {params.success(stubAttachment);}); var uploadedAttachment = spyOnEvent(document, Pixelated.events.mail.uploadedAttachment); var uploading = spyOnEvent(document, Pixelated.events.mail.uploadingAttachment); diff --git a/web-ui/test/spec/mail_view/ui/draft_box.spec.js b/web-ui/test/spec/mail_view/ui/draft_box.spec.js index 96880adf..f095f5e5 100644 --- a/web-ui/test/spec/mail_view/ui/draft_box.spec.js +++ b/web-ui/test/spec/mail_view/ui/draft_box.spec.js @@ -34,7 +34,7 @@ describeComponent('mail_view/ui/draft_box', function () { expect(this.component.render).toHaveBeenCalledWith(templates.compose.box, { recipients: { to: mail.header.to, cc: mail.header.cc, bcc: mail.header.bcc }, - subject: mail.header.subject, + subject: mail.header.subject, attachments: [], body: mail.textPlainBody }); }); |