summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipients_input.js10
-rw-r--r--web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js16
2 files changed, 17 insertions, 9 deletions
diff --git a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js
index 12c5c340..c1c32d77 100644
--- a/web-ui/app/js/mail_view/ui/recipients/recipients_input.js
+++ b/web-ui/app/js/mail_view/ui/recipients/recipients_input.js
@@ -99,7 +99,7 @@ define([
};
this.tokenizeRecipient = function (event) {
- if (_.isEmpty(this.$node.val())) {
+ if (_.isEmpty(this.$node.val().trim())) {
return;
}
@@ -109,8 +109,12 @@ define([
this.recipientSelected = function (event, data) {
var value = (data && data.value) || this.$node.val();
-
- this.trigger(this.$node, events.ui.recipients.entered, { name: this.attr.name, address: value });
+ var that = this;
+ _.each(value.split(/[,;]/), function(address) {
+ if (!_.isEmpty(address.trim())) {
+ that.trigger(that.$node, events.ui.recipients.entered, { name: that.attr.name, address: address.trim() });
+ }
+ });
reset(this.$node);
};
diff --git a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
index 433c145b..d4fb8faf 100644
--- a/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
+++ b/web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js
@@ -124,16 +124,20 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
});
describe('on blur', function() {
- it('tokenizes recipient email if there is an input val', function() {
+ it('tokenizes and sanitize recipient email if there is an input val', function() {
var addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered);
var blurEvent = $.Event('blur');
- spyOn(blurEvent, 'preventDefault');
+ spyOn(blurEvent, 'preventDefault');
- this.$node.val('a@b.c');
- this.$node.trigger(blurEvent);
+ this.$node.val('a@b.c, Friend <friend@domain.com>; d@e.f , , , , , , , ,');
+ this.$node.trigger(blurEvent);
- expect(blurEvent.preventDefault).toHaveBeenCalled();
- expect(addressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, {name: 'to', address: 'a@b.c'});
+ expect(blurEvent.preventDefault).toHaveBeenCalled();
+ expect(addressEnteredEvent.callCount).toEqual(3);
+
+ expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'a@b.c'});
+ expect(addressEnteredEvent.calls[1].data).toEqual({name: 'to', address: 'Friend <friend@domain.com>'});
+ expect(addressEnteredEvent.calls[2].data).toEqual({name: 'to', address: 'd@e.f'});
})
});
});