diff options
author | Ola Bini <ola.bini@gmail.com> | 2014-07-31 19:29:33 -0300 |
---|---|---|
committer | Ola Bini <ola.bini@gmail.com> | 2014-07-31 19:29:33 -0300 |
commit | 04cf441c5ae18400c6b4865b0b37a71718dc9d46 (patch) | |
tree | dd0b0d049ec00389e2d4561b226c46eb1682b997 /web-ui/test/spec/mail_view/ui/reply_section.spec.js | |
parent | 639a663a4c37020003586438fdcd7ac529a00f10 (diff) |
Add web-ui based on previous code
Diffstat (limited to 'web-ui/test/spec/mail_view/ui/reply_section.spec.js')
-rw-r--r-- | web-ui/test/spec/mail_view/ui/reply_section.spec.js | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/web-ui/test/spec/mail_view/ui/reply_section.spec.js b/web-ui/test/spec/mail_view/ui/reply_section.spec.js new file mode 100644 index 00000000..e5571e2c --- /dev/null +++ b/web-ui/test/spec/mail_view/ui/reply_section.spec.js @@ -0,0 +1,97 @@ +/*global jasmine */ +/*global Smail */ + +describeComponent('mail_view/ui/reply_section', function () { + 'use strict'; + + beforeEach(function () { + setupComponent(); + }); + + describe('clicking reply buttons', function() { + var mailWantEvent, expectEventData; + + beforeEach(function () { + mailWantEvent = spyOnEvent(document, Smail.events.mail.want); + expectEventData = { + mail: '12345', + caller: this.component + }; + this.component.attr.ident = '12345'; + }); + + it('should ask for email when clicking on reply button', function() { + this.component.select('replyButton').click(); + + expect(mailWantEvent).toHaveBeenTriggeredOnAndWith(document, expectEventData); + }); + + it('should ask for email when clicking on replyAll button', function() { + this.component.select('replyAllButton').click(); + + expect(mailWantEvent).toHaveBeenTriggeredOnAndWith(document, expectEventData); + }); + }); + + describe('creating reply box when getting email back', function() { + var mailData, ReplyBox, ForwardBox; + + beforeEach(function () { + mailData = Smail.testData().mail; + ReplyBox = require('mail_view/ui/reply_box'); + ForwardBox = require('mail_view/ui/forward_box'); + spyOn(ReplyBox, 'attachTo'); + spyOn(ForwardBox, 'attachTo'); + }); + + it('for normal reply', function() { + this.component.attr.replyType = 'reply'; + this.component.trigger(this.component, Smail.events.mail.here, { mail: mailData }); + + expect(ReplyBox.attachTo).toHaveBeenCalledWith(jasmine.any(Object), { + mail: mailData, + replyType: 'reply' + }); + }); + + it('for reply to all', function() { + this.component.attr.replyType = 'replyall'; + this.component.trigger(this.component, Smail.events.mail.here, { mail: mailData }); + + expect(ReplyBox.attachTo).toHaveBeenCalledWith(jasmine.any(Object), { + mail: mailData, + replyType: 'replyall' + }); + }); + + it('creates a forward box', function() { + this.component.attr.replyType = 'forward'; + this.component.trigger(this.component, Smail.events.mail.here, { mail: mailData }); + + expect(ForwardBox.attachTo).toHaveBeenCalledWith(jasmine.any(Object), { + mail: mailData + }); + }); + }); + + it('hides the buttons when clicked', function() { + this.component.attr.mailIdent = 12345; + + this.component.select('replyButton').click(); + + expect(this.component.select('replyButton')).toBeHidden(); + expect(this.component.select('replyAllButton')).toBeHidden(); + expect(this.component.select('forwardButton')).toBeHidden(); + }); + + it('shows the buttons when reply is cancelled', function() { + this.component.attr.mailIdent = 12345; + this.component.select('replyButton').click(); + + $(document).trigger(Smail.events.ui.composeBox.trashReply); + + expect(this.component.select('replyButton')).not.toBeHidden(); + expect(this.component.select('replyAllButton')).not.toBeHidden(); + expect(this.component.select('forwardButton')).not.toBeHidden(); + }); +}); |