diff options
author | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-12-08 20:56:52 +0000 |
---|---|---|
committer | Patrick Maia <patrickjourdanmaia@gmail.com> | 2014-12-09 00:45:03 +0000 |
commit | b636c1d8c3c4fe86f08a141d6009603163597059 (patch) | |
tree | 06bb2c331102be8eeea6ff0d4a9d7bab203bae74 /web-ui/test/spec/mail_view/ui | |
parent | a67a232fd026069de44e701278d2750c3440e677 (diff) |
Card #168 - does not accept obviously invalid email addresses
Diffstat (limited to 'web-ui/test/spec/mail_view/ui')
-rw-r--r-- | web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js | 46 |
1 files changed, 38 insertions, 8 deletions
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 d4fb8faf..8e7a526c 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,14 +13,24 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { ], function (keycode) { - it(': ' + keycode[1], function () { + it('adds the address if its a valid 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('a@b.c'); + 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.trigger(enterAddressKeyPressEvent); - expect(addressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'a@b.c' }); + expect(addressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'My dear friend <a@b.com>' }); }); it('wont add address if val is empty: ' + keycode[1], function () { @@ -33,6 +43,26 @@ 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); @@ -66,11 +96,11 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { var tabKeyPressEvent = $.Event('keydown', { which: 9}); spyOn(tabKeyPressEvent, 'preventDefault'); - this.$node.val('a@b.c'); + this.$node.val('a@b.com'); this.$node.trigger(tabKeyPressEvent); expect(tabKeyPressEvent.preventDefault).toHaveBeenCalled(); - expect(addressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'a@b.c'}); + expect(addressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'a@b.com'}); }); it('doesnt enter an address and doesnt prevent event default if input val is empty (so tab moves it to the next input)', function () { @@ -129,15 +159,15 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { var blurEvent = $.Event('blur'); spyOn(blurEvent, 'preventDefault'); - this.$node.val('a@b.c, Friend <friend@domain.com>; d@e.f , , , , , , , ,'); + this.$node.val('a@b.com, Friend <friend@domain.com>; d@e.fr , , , , , , , ,'); this.$node.trigger(blurEvent); expect(blurEvent.preventDefault).toHaveBeenCalled(); expect(addressEnteredEvent.callCount).toEqual(3); - expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'a@b.c'}); + expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'a@b.com'}); 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'}); + expect(addressEnteredEvent.calls[2].data).toEqual({name: 'to', address: 'd@e.fr'}); }) }); }); |