summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/mail_view/data
diff options
context:
space:
mode:
authorNavaL <mnandri@thoughtworks.com>2015-12-27 15:58:24 +0100
committerNavaL <mnandri@thoughtworks.com>2015-12-29 19:03:43 +0100
commit98082de00c79e764ee489397de9ec818f51f0dba (patch)
tree531709e46643003553d57226ee77740a26d5b18f /web-ui/test/spec/mail_view/data
parent5dca3fda432c12cd63ab4c8011aa2ea74ce1a771 (diff)
refactoring: moved upload logic out of the attachment icon
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.js34
1 files changed, 29 insertions, 5 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 74c1dea7..f1fa0e76 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,9 +1,11 @@
-describeMixin('mail_view/data/attachment_list', function () {
- 'use strict';
+describeComponent('mail_view/data/attachment_list', function () {
+ 'use strict';
- describe('initialization', function() {
- beforeEach(function(){
- this.setupComponent();
+ describe('initialization', function () {
+ beforeEach(function () {
+ this.setupComponent('<div id="attachment-list">' +
+ '<ul><li id="attachment-list-item"> </li></ul>' +
+ '</div>');
});
it('should add attachment to the list based on uploadedAttachment event', function () {
@@ -16,6 +18,28 @@ describeMixin('mail_view/data/attachment_list', function () {
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&amp;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);
+ });
+
});
});