summaryrefslogtreecommitdiff
path: root/web-ui/test
diff options
context:
space:
mode:
authorGiovane <giovaneliberato@gmail.com>2015-11-27 15:47:58 -0200
committerGiovane <giovaneliberato@gmail.com>2015-11-27 15:53:11 -0200
commit07be9f6109e3dff49775aa51f0a481b5fd524d3b (patch)
tree29e2df328027c60349d17a8f62fdd556fafceeb3 /web-ui/test
parentc1476b4b1c96996464217444e8cdf5d94d248bea (diff)
Created a discard draft behaviour #512 w/ bwagner
If a draft was never saved before, and there wasn't any change to save, we now discard it instead saving and deleting it. This also lessens the calls to saveDraft that was causing some draft duplication.
Diffstat (limited to 'web-ui/test')
-rw-r--r--web-ui/test/spec/mail_view/ui/reply_box.spec.js8
-rw-r--r--web-ui/test/spec/mixins/with_mail_edit_base.spec.js23
2 files changed, 20 insertions, 11 deletions
diff --git a/web-ui/test/spec/mail_view/ui/reply_box.spec.js b/web-ui/test/spec/mail_view/ui/reply_box.spec.js
index 9542f37a..731d57b3 100644
--- a/web-ui/test/spec/mail_view/ui/reply_box.spec.js
+++ b/web-ui/test/spec/mail_view/ui/reply_box.spec.js
@@ -82,14 +82,6 @@ describeComponent('mail_view/ui/reply_box', function () {
expect(this.component.select('bodyBox').val()).toBe('quoted email');
});
- it('triggers mail when cancelling a reply', function () {
- var mailSaveEvent = spyOnEvent(document, Pixelated.events.mail.save);
-
- this.component.select('trashButton').click();
-
- expect(mailSaveEvent).toHaveBeenTriggeredOn(document);
- });
-
it('reopens the mail after the reply is sent', function () {
var mailOpenEvent = spyOnEvent(document, Pixelated.events.ui.mail.open);
diff --git a/web-ui/test/spec/mixins/with_mail_edit_base.spec.js b/web-ui/test/spec/mixins/with_mail_edit_base.spec.js
index 601f2c11..2ad12361 100644
--- a/web-ui/test/spec/mixins/with_mail_edit_base.spec.js
+++ b/web-ui/test/spec/mixins/with_mail_edit_base.spec.js
@@ -2,12 +2,14 @@ describeMixin('mixins/with_mail_edit_base', function () {
'use strict';
beforeEach(function () {
+ this.Component.discardDraft = function () {};
this.setupComponent();
// Stubing mixing wrongly!!! 'deprecated' while waiting for draft component extraction
this.component.buildMail = function (tag) {
return { header: { to: ['a@smth.com'], from: 'b@smth.com', subject: 'Sbject' } };
};
+
spyOn(this.component, 'trim_recipient').and.callFake(function(recipients) {
return recipients.map(function(recipient) {
return recipient.trim();
@@ -66,11 +68,26 @@ describeMixin('mixins/with_mail_edit_base', function () {
});
});
- describe('when user asks to trash the mail', function() {
- it('triggers mail delete for this mail', function() {
+ describe('when user asks to discard the mail', function() {
+ var mailSaveSpy, mailDiscardSpy;
+
+ beforeEach(function () {
+ mailSaveSpy = spyOnEvent(document, Pixelated.events.mail.save);
+ mailDiscardSpy = spyOnEvent(document, Pixelated.events.ui.mail.discard);
+ });
+
+ it('discards the mail if it was never saved', function() {
+ delete this.component.attr.ident;
+ this.component.trashMail();
+ expect(mailSaveSpy).not.toHaveBeenTriggeredOn(document);
+ expect(mailDiscardSpy).toHaveBeenTriggeredOn(document);
+ });
+
+ it('deletes the draft if it was saved before', function() {
var spy = spyOnEvent(document, Pixelated.events.mail.save);
+ this.component.attr.ident = 'ident';
this.component.trashMail();
- expect(spy).toHaveBeenTriggeredOn(document);
+ expect(mailSaveSpy).toHaveBeenTriggeredOn(document);
});
});