From 9bc9f6a2ecf6fbb8092a99fa9d6abbfabc0cc800 Mon Sep 17 00:00:00 2001 From: Giovane Date: Thu, 22 Oct 2015 15:56:18 -0200 Subject: Extract js code duplication to beforeEach method. --- .../spec/mail_view/ui/recipients/recipients_input.spec.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'web-ui') 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 90acf85f..6b05d1b6 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 @@ -125,11 +125,15 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { }); describe('on blur', 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'); + var addressEnteredEvent, blurEvent; + + beforeEach(function() { + addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered); + blurEvent = $.Event('blur'); spyOn(blurEvent, 'preventDefault'); + }); + it('tokenizes and sanitize recipient email if there is an input val', function() { this.$node.val('a@b.c, Friend ; d@e.f , , , , , , , ,'); this.$node.trigger(blurEvent); @@ -142,10 +146,6 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { }); it('tokenizes and sanitize adresses separated by space, comma and semicolon', function() { - var addressEnteredEvent = spyOnEvent(this.$node, Pixelated.events.ui.recipients.entered); - var blurEvent = $.Event('blur'); - spyOn(blurEvent, 'preventDefault'); - this.$node.val('a@b.c Friend , d@e.f; g@h.i'); this.$node.trigger(blurEvent); @@ -157,6 +157,5 @@ describeComponent('mail_view/ui/recipients/recipients_input',function () { expect(addressEnteredEvent.calls[2].data).toEqual({name: 'to', address: 'd@e.f'}); expect(addressEnteredEvent.calls[3].data).toEqual({name: 'to', address: 'g@h.i'}); }); - }); }); -- cgit v1.2.3