summaryrefslogtreecommitdiff
path: root/web-ui/test/spec
diff options
context:
space:
mode:
Diffstat (limited to 'web-ui/test/spec')
-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);
});
});