summaryrefslogtreecommitdiff
path: root/web-ui/test/spec/mail_view/data
diff options
context:
space:
mode:
authorDuda Dornelles <ddornell@thoughtworks.com>2015-02-18 13:17:30 -0200
committerDuda Dornelles <ddornell@thoughtworks.com>2015-02-18 13:40:49 -0200
commit4a8217744e1d1ca60d158c3497a09b92f857a7fd (patch)
tree3d3e52ca752567078abc27da4752d8d20a624984 /web-ui/test/spec/mail_view/data
parent45aa91442ad6f78b4cc99da77506058c13f6b98f (diff)
#294 - using server error message on ajax if message is provided
Diffstat (limited to 'web-ui/test/spec/mail_view/data')
-rw-r--r--web-ui/test/spec/mail_view/data/mail_sender.spec.js25
1 files changed, 5 insertions, 20 deletions
diff --git a/web-ui/test/spec/mail_view/data/mail_sender.spec.js b/web-ui/test/spec/mail_view/data/mail_sender.spec.js
index 9b6c2828..6a1d356c 100644
--- a/web-ui/test/spec/mail_view/data/mail_sender.spec.js
+++ b/web-ui/test/spec/mail_view/data/mail_sender.spec.js
@@ -47,29 +47,14 @@ describeComponent('mail_view/data/mail_sender', function () {
expect(JSON.parse($.ajax.calls.mostRecent().args[1].data).body).toEqual(mail.body);
});
- it('displays generic error message when sending an email fails in the service', function () {
- var deferred;
- deferred = $.Deferred();
- deferred.reject({responseJSON: {}}, 500, 'Internal Server Error');
-
- var messageEvent = spyOnEvent(document, Pixelated.events.ui.userAlerts.displayMessage);
- spyOn($, 'ajax').and.returnValue(deferred);
+ it('uses the monitored ajax call to delegate for errors', function () {
+ var monitoredAjaxCall = require('helpers/monitored_ajax');
+ spyOn(monitoredAjaxCall, 'call').and.returnValue($.Deferred());
this.component.trigger(Pixelated.events.mail.send, mail);
+ this.component.trigger(Pixelated.events.mail.saveDraft, mail);
- expect(messageEvent).toHaveBeenTriggeredOnAndWith(document, {message: 'Ops! something went wrong, try again later.'});
+ expect(monitoredAjaxCall.call.calls.count()).toEqual(2);
});
- it('displays error message returned by the service when sending an email fails in the service', function () {
- var deferred;
- deferred = $.Deferred();
- deferred.reject({responseJSON: {message: 'test: error message'}}, 422, 'Unprocessable Entity');
-
- var messageEvent = spyOnEvent(document, Pixelated.events.ui.userAlerts.displayMessage);
- spyOn($, 'ajax').and.returnValue(deferred);
-
- this.component.trigger(Pixelated.events.mail.send, mail);
-
- expect(messageEvent).toHaveBeenTriggeredOnAndWith(document, {message: 'Error sending mail: test: error message'});
- });
});