summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/mail_view
diff options
context:
space:
mode:
authorNavaL <mnandri@thoughtworks.com>2016-01-05 19:44:07 +0100
committerNavaL <mnandri@thoughtworks.com>2016-01-05 19:45:38 +0100
commit17695c1c9037d9edc927fb5265d380384eb6866a (patch)
tree44e26d41fec052c9b641d0eba0c92f625680c263 /web-ui/test/spec/mail_view
parent0ca01a8a8e2cd9201f43fa840a30a0822215bfef (diff)
emptying attachment list when email sent -- in case the user stays on the same screen and re-click compose
Issue #548
Diffstat (limited to 'web-ui/test/spec/mail_view')
-rw-r--r--web-ui/test/spec/mail_view/data/attachment_list.spec.js14
-rw-r--r--web-ui/test/spec/mail_view/ui/attachment_list.spec.js14
-rw-r--r--web-ui/test/spec/mail_view/ui/compose_box.spec.js1
3 files changed, 26 insertions, 3 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 3d93537b..45167e33 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
@@ -16,6 +16,20 @@ describeMixin('mail_view/data/attachment_list', function () {
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 c66b959c..8bbc9f1a 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
@@ -4,7 +4,7 @@ describeComponent('mail_view/ui/attachment_list', function () {
describe('initialization', function () {
beforeEach(function () {
this.setupComponent('<div id="attachment-list">' +
- '<ul><li id="attachment-list-item"> </li></ul>' +
+ '<ul id="attachment-list-item"></ul>' +
'</div>');
});
@@ -22,10 +22,20 @@ describeComponent('mail_view/ui/attachment_list', function () {
$(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>';
+ var expected_li = '<li><a href="/attachment/faked?filename=haha.txt&amp;encoding=base64">haha.txt (4.39 Kb)</a></li>';
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 mockAjax = spyOn($, 'ajax').and.callFake(function (params) {params.success(stubAttachment);});
diff --git a/web-ui/test/spec/mail_view/ui/compose_box.spec.js b/web-ui/test/spec/mail_view/ui/compose_box.spec.js
index 84f1e0ed..6d318815 100644
--- a/web-ui/test/spec/mail_view/ui/compose_box.spec.js
+++ b/web-ui/test/spec/mail_view/ui/compose_box.spec.js
@@ -13,7 +13,6 @@ describeComponent('mail_view/ui/compose_box', function () {
describe('compose new mail', function() {
-
it('only sends if all the recipients are valid emails', function() {
$(document).trigger(Pixelated.events.ui.recipients.updated, {recipientsName: 'to', newRecipients: ['valid@email.example']});