summaryrefslogtreecommitdiff
path: root/web-ui
diff options
context:
space:
mode:
authorPatrick Maia <patrickjourdanmaia@gmail.com>2014-12-11 19:10:44 +0000
committerPatrick Maia <patrickjourdanmaia@gmail.com>2014-12-12 16:20:29 +0000
commita0318266427bcb8c1f00f82f9afab9e444d8d2f4 (patch)
tree7ab35e12083369a343bedaae148e2b3003b0d560 /web-ui
parent5b539c61f559ec45287f6911d82f13dbbcae4552 (diff)
Revert "Card #168 - does not accept obviously invalid email addresses"
This reverts commit b636c1d8c3c4fe86f08a141d6009603163597059.
Diffstat (limited to 'web-ui')
-rw-r--r--web-ui/app/js/mail_view/ui/recipients/recipients_input.js7
-rw-r--r--web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js46
2 files changed, 9 insertions, 44 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 ef860eb0..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
@@ -111,18 +111,13 @@ define([
var value = (data && data.value) || this.$node.val();
var that = this;
_.each(value.split(/[,;]/), function(address) {
- if(that.isValidEmailAddress(address.trim())) {
+ if (!_.isEmpty(address.trim())) {
that.trigger(that.$node, events.ui.recipients.entered, { name: that.attr.name, address: address.trim() });
}
});
reset(this.$node);
};
- this.isValidEmailAddress = function(address) {
- // valid emails are in the format: 'user@domain.smt' or 'User <user@domain.smt>'
- return /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}|[A-Z ]+<[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}>$/i.test(address);
- };
-
this.init = function () {
this.$node.typeahead({
hint: true,
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 8e7a526c..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
@@ -13,24 +13,14 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
], function (keycode) {
- it('adds the address if its a valid emails address: ' + keycode[1], function () {
+ it(': ' + keycode[1], function () {
var addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered);
var enterAddressKeyPressEvent = $.Event('keydown', { which: keycode[0] });
- this.$node.val('a@b.com');
- this.$node.trigger(enterAddressKeyPressEvent);
-
- expect(addressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'a@b.com' });
- });
-
- it('adds the address if its a valid formatted emails address: ' + keycode[1], function () {
- var addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered);
-
- var enterAddressKeyPressEvent = $.Event('keydown', { which: keycode[0] });
- this.$node.val('My dear friend <a@b.com>');
+ this.$node.val('a@b.c');
this.$node.trigger(enterAddressKeyPressEvent);
- expect(addressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'My dear friend <a@b.com>' });
+ expect(addressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'a@b.c' });
});
it('wont add address if val is empty: ' + keycode[1], function () {
@@ -43,26 +33,6 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
expect(addressEnteredEvent).not.toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: '' });
});
- it('wont add address if val is not a valid email address: ' + keycode[1], function () {
- var addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered);
-
- var enterAddressKeyPressEvent = $.Event('keydown', { which: keycode[0] });
- this.$node.val('abacate');
- this.$node.trigger(enterAddressKeyPressEvent);
-
- expect(addressEnteredEvent).not.toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'abacate' });
- });
-
- it('wont add address if val is not a valid formatted email address: ' + keycode[1], function () {
- var addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered);
-
- var enterAddressKeyPressEvent = $.Event('keydown', { which: keycode[0] });
- this.$node.val('abacate <coisa>');
- this.$node.trigger(enterAddressKeyPressEvent);
-
- expect(addressEnteredEvent).not.toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'abacate <coisa>' });
- });
-
it('wont add address if shift key is pressed together: ' + keycode[1], function () {
var addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered);
@@ -96,11 +66,11 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
var tabKeyPressEvent = $.Event('keydown', { which: 9});
spyOn(tabKeyPressEvent, 'preventDefault');
- this.$node.val('a@b.com');
+ this.$node.val('a@b.c');
this.$node.trigger(tabKeyPressEvent);
expect(tabKeyPressEvent.preventDefault).toHaveBeenCalled();
- expect(addressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'a@b.com'});
+ expect(addressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'a@b.c'});
});
it('doesnt enter an address and doesnt prevent event default if input val is empty (so tab moves it to the next input)', function () {
@@ -159,15 +129,15 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () {
var blurEvent = $.Event('blur');
spyOn(blurEvent, 'preventDefault');
- this.$node.val('a@b.com, Friend <friend@domain.com>; d@e.fr , , , , , , , ,');
+ this.$node.val('a@b.c, Friend <friend@domain.com>; d@e.f , , , , , , , ,');
this.$node.trigger(blurEvent);
expect(blurEvent.preventDefault).toHaveBeenCalled();
expect(addressEnteredEvent.callCount).toEqual(3);
- expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'a@b.com'});
+ 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.fr'});
+ expect(addressEnteredEvent.calls[2].data).toEqual({name: 'to', address: 'd@e.f'});
})
});
});