diff options
| author | NavaL <mnandri@thoughtworks.com> | 2016-01-05 15:10:33 +0100 |
|---|---|---|
| committer | NavaL <mnandri@thoughtworks.com> | 2016-01-05 19:45:38 +0100 |
| commit | 0ca01a8a8e2cd9201f43fa840a30a0822215bfef (patch) | |
| tree | 2cb37ab0055f39a2d3ef384cceb6a75f5b47e977 /web-ui/test/spec/mail_view/data | |
| parent | 29bfdd509d88aef16873207683302bec22bfe5a9 (diff) | |
separated attachment list UI as a component and the corresponding attachment list payload as a mixin
Issue #548
Diffstat (limited to 'web-ui/test/spec/mail_view/data')
| -rw-r--r-- | web-ui/test/spec/mail_view/data/attachment_list.spec.js | 38 |
1 files changed, 7 insertions, 31 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 index f1fa0e76..3d93537b 100644 --- a/web-ui/test/spec/mail_view/data/attachment_list.spec.js +++ b/web-ui/test/spec/mail_view/data/attachment_list.spec.js @@ -1,45 +1,21 @@ -describeComponent('mail_view/data/attachment_list', function () { - 'use strict'; +describeMixin('mail_view/data/attachment_list', function () { + 'use strict'; - describe('initialization', function () { - beforeEach(function () { - this.setupComponent('<div id="attachment-list">' + - '<ul><li id="attachment-list-item"> </li></ul>' + - '</div>'); + 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); + $(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.uploadedAttachment, anotherStubAttachment); + $(document).trigger(Pixelated.events.mail.appendAttachment, anotherStubAttachment); expect(this.component.attr.attachments).toEqual([stubAttachment, anotherStubAttachment]); }); - it('should render attachment list view based on uploadedAttachment event', function () { - var stubAttachment = {attachment_id: 'faked', filename: 'haha.txt', filesize: 4500}; - - $(document).trigger(Pixelated.events.mail.uploadedAttachment, stubAttachment); - - var expected_li = '<a href="/attachment/faked?filename=haha.txt&encoding=base64">haha.txt (4.39 Kb)</a>'; - expect(this.component.select('attachmentListItem').html()).toEqual(expected_li); - }); - - xit('should start uploading attachments', function () { - var stubAttachment = {attachment_id: 'faked', filename: 'haha.txt', filesize: 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); - - $(document).trigger(Pixelated.events.mail.startUploadAttachment); - - expect(mockAjax).toHaveBeenCalled(); - expect(uploadedAttachment).toHaveBeenTriggeredOnAndWith(document, stubAttachment); - expect(uploading).toHaveBeenTriggeredOn(document); - }); - }); }); |
