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 | |
parent | 9bc9f6a2ecf6fbb8092a99fa9d6abbfabc0cc800 (diff) |
Add invalid address sinalization on tokens #492
Diffstat (limited to 'web-ui/test')
-rw-r--r-- | web-ui/test/spec/mail_view/ui/recipients/recipients.spec.js | 21 | ||||
-rw-r--r-- | web-ui/test/spec/mail_view/ui/recipients/recipients_input.spec.js | 29 |
2 files changed, 49 insertions, 1 deletions
diff --git a/web-ui/test/spec/mail_view/ui/recipients/recipients.spec.js b/web-ui/test/spec/mail_view/ui/recipients/recipients.spec.js index 7dd9000f..a3b3381f 100644 --- a/web-ui/test/spec/mail_view/ui/recipients/recipients.spec.js +++ b/web-ui/test/spec/mail_view/ui/recipients/recipients.spec.js @@ -26,15 +26,34 @@ describeComponent('mail_view/ui/recipients/recipients',function () { beforeEach(function () { this.setupComponent(); recipientsUpdatedEvent = spyOnEvent(document, Pixelated.events.ui.recipients.updated); - this.component.trigger(Pixelated.events.ui.recipients.entered, {name: 'to', addresses: ['foobar@gmail.com'] }); }); it('triggers recipients updated', function() { + this.component.trigger(Pixelated.events.ui.recipients.entered, {name: 'to', addresses: ['foobar@gmail.com'] }); expect(recipientsUpdatedEvent).toHaveBeenTriggeredOn(document); }); it('adds recipients', function() { + this.component.trigger(Pixelated.events.ui.recipients.entered, {name: 'to', addresses: ['foobar@gmail.com'] }); + expect(this.component.attr.recipients.length).toBe(1); + }); + }); + + describe('adding invalid recipients from the ui', function() { + beforeEach(function () { + this.setupComponent(); + recipientsUpdatedEvent = spyOnEvent(document, Pixelated.events.ui.recipients.updated); + this.component.trigger(Pixelated.events.ui.recipients.enteredInvalid, {name: 'to', addresses: ['invalid.com'] }); + }); + + it('does not trigger recipients updated', function() { + expect(recipientsUpdatedEvent).not.toHaveBeenTriggeredOn(document); + }); + + it('adds recipients with invalid indication', function() { expect(this.component.attr.recipients.length).toBe(1); + expect(this.component.attr.recipients[0].attr.invalidAddress).toBe(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 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'}); + }); + + }); }); |