diff options
author | Giovane <giovaneliberato@gmail.com> | 2015-10-23 12:19:19 -0200 |
---|---|---|
committer | Giovane <giovaneliberato@gmail.com> | 2015-10-23 12:23:12 -0200 |
commit | 72e332e2969d4eb36c9cd64336c1f1d89b6185f1 (patch) | |
tree | cfa8bfe38eb2449a57ebdbe7c0bc3b96da14f075 /web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js | |
parent | 9bc9f6a2ecf6fbb8092a99fa9d6abbfabc0cc800 (diff) |
Add invalid address sinalization on tokens #492
Diffstat (limited to 'web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js')
-rw-r--r-- | web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js | 29 |
1 files changed, 29 insertions, 0 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 6b05d1b6..1656a83a 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 @@ -158,4 +158,33 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { expect(addressEnteredEvent.calls[3].data).toEqual({name: 'to', address: 'g@h.i'}); }); }); + + describe('when entering an invalid address', function() { + var invalidAddressEnteredEvent, addressEnteredEvent, blurEvent; + + beforeEach(function () { + invalidAddressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.enteredInvalid); + addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered); + blurEvent = $.Event('blur'); + spyOn(blurEvent, 'preventDefault'); + }); + + it('displays it as an invalid address token', function() { + this.$node.val('invalid'); + this.$node.trigger(blurEvent); + + expect(blurEvent.preventDefault).toHaveBeenCalled(); + expect(invalidAddressEnteredEvent).toHaveBeenTriggeredOnAndWith(this, { name: 'to', address: 'invalid' }); + }); + + it('displays it as an invalid address token when cannot parse', function() { + this.$node.val('invalid_format email@example.com'); + this.$node.trigger(blurEvent); + + expect(blurEvent.preventDefault).toHaveBeenCalled(); + expect(invalidAddressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'invalid_format'}); + expect(addressEnteredEvent.calls[0].data).toEqual({name: 'to', address: 'email@example.com'}); + }); + + }); }); |