summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web-ui/app/js/mixins/with_mail_edit_base.js11
-rw-r--r--web-ui/test/spec/mixins/with_mail_edit_base.spec.js12
2 files changed, 18 insertions, 5 deletions
diff --git a/web-ui/app/js/mixins/with_mail_edit_base.js b/web-ui/app/js/mixins/with_mail_edit_base.js
index 181af736..fe73c03c 100644
--- a/web-ui/app/js/mixins/with_mail_edit_base.js
+++ b/web-ui/app/js/mixins/with_mail_edit_base.js
@@ -59,12 +59,17 @@ define(
};
function thereAreRecipientsToDisplay() {
- return this.attr.recipientValues.to &&
- this.attr.recipientValues.cc &&
- !_.isEmpty(this.attr.recipientValues.to.concat(this.attr.recipientValues.cc));
+ var allRecipients = _.chain(this.attr.recipientValues).
+ values().
+ flatten().
+ remove(undefined).
+ value();
+
+ return !_.isEmpty(allRecipients);
}
this.render = function(template, context) {
+ debugger;
this.$node.html(template(context));
if(!context || _.isEmpty(context)){
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 35ec0eb6..10b7d04c 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
@@ -17,21 +17,29 @@ describeMixin('mixins/with_mail_edit_base', function () {
describe('initialization', function() {
it('should enable send button when rendering with recipients', function() {
var enableSendButtonEvent = spyOnEvent(document, Pixelated.events.ui.sendbutton.enable);
-
this.component.render(function() {}, {
recipients: { to: ['foobar@mail.com'], cc: [] }
});
+ expect(enableSendButtonEvent).toHaveBeenTriggeredOn(document);
+ enableSendButtonEvent = spyOnEvent(document, Pixelated.events.ui.sendbutton.enable);
+ this.component.render(function() {}, {
+ recipients: { to: ['foobar@mail.com'], cc: undefined }
+ });
expect(enableSendButtonEvent).toHaveBeenTriggeredOn(document);
});
it('should not enable send button when rendering without recipients', function() {
var enableSendButtonEvent = spyOnEvent(document, Pixelated.events.ui.sendbutton.enable);
-
this.component.render(function() {}, {
recipients: { to: [], cc: [] }
});
+ expect(enableSendButtonEvent).not.toHaveBeenTriggeredOn(document);
+ enableSendButtonEvent = spyOnEvent(document, Pixelated.events.ui.sendbutton.enable);
+ this.component.render(function() {}, {
+ recipients: { to: undefined, cc: undefined }
+ });
expect(enableSendButtonEvent).not.toHaveBeenTriggeredOn(document);
});
});