diff options
-rw-r--r-- | web-ui/app/js/mail_view/ui/feedback_box.js | 12 | ||||
-rw-r--r-- | web-ui/app/js/page/events.js | 1 | ||||
-rw-r--r-- | web-ui/test/spec/mail_view/ui/feedback_box.spec.js | 14 |
3 files changed, 17 insertions, 10 deletions
diff --git a/web-ui/app/js/mail_view/ui/feedback_box.js b/web-ui/app/js/mail_view/ui/feedback_box.js index 5a04e291..f6994554 100644 --- a/web-ui/app/js/mail_view/ui/feedback_box.js +++ b/web-ui/app/js/mail_view/ui/feedback_box.js @@ -23,6 +23,7 @@ define(['flight/lib/component', 'views/templates', 'page/events', 'features'], this.defaultAttrs({ 'closeButton': '.close-mail-button', 'submitButton': '#send-button', + 'textBox': '#text-box', }); this.render = function () { @@ -40,17 +41,18 @@ define(['flight/lib/component', 'views/templates', 'page/events', 'features'], this.trigger(document, events.dispatchers.rightPane.openNoMessageSelected); }; - this.showFeedbackSubmittedMessage = function() { - this.trigger(document, events.ui.userAlerts.displayMessage, { message: 'Thanks for your feedback!' }); - }; + this.submitFeedback = function () { + var feedback = this.select('textBox').val(); + this.trigger(document, events.feedback.submit, { feedback: feedback}); + } this.after('initialize', function () { if (features.isEnabled('feedback')) { this.render(); this.on(document, events.dispatchers.rightPane.openFeedbackBox, this.openFeedbackBox); + this.on(document, events.feedback.submitted, this.showNoMessageSelected); this.on(this.select('closeButton'), 'click', this.showNoMessageSelected); - this.on(this.select('submitButton'), 'click', this.showNoMessageSelected); - this.on(this.select('submitButton'), 'click', this.showFeedbackSubmittedMessage); + this.on(this.select('submitButton'), 'click', this.submitFeedback); } }); diff --git a/web-ui/app/js/page/events.js b/web-ui/app/js/page/events.js index 4d90fff9..0196ee24 100644 --- a/web-ui/app/js/page/events.js +++ b/web-ui/app/js/page/events.js @@ -100,6 +100,7 @@ define(function () { resetHighlight: 'search:resetHighlight' }, feedback: { + submit: 'feedback:submit', submitted: 'feedback:submitted' }, mail: { diff --git a/web-ui/test/spec/mail_view/ui/feedback_box.spec.js b/web-ui/test/spec/mail_view/ui/feedback_box.spec.js index ab41c7d1..a034b028 100644 --- a/web-ui/test/spec/mail_view/ui/feedback_box.spec.js +++ b/web-ui/test/spec/mail_view/ui/feedback_box.spec.js @@ -17,15 +17,19 @@ describeComponent('mail_view/ui/feedback_box', function () { }); describe('when submit feedback', function () { - it('should display submitted message', function() { - var spy = spyOnEvent(document, Pixelated.events.ui.userAlerts.displayMessage); + + it('should fire submit feedback event', function () { + var spy = spyOnEvent(document, Pixelated.events.feedback.submit); + + this.component.select("textBox").val("Pixelated is Awesome!"); this.component.select('submitButton').click(); - expect(spy).toHaveBeenTriggeredOnAndWith(document, { message: 'Thanks for your feedback!' }); - }); + expect(spy).toHaveBeenTriggeredOnAndWith(document, {feedback: "Pixelated is Awesome!"}); + }) it('should close feedback box after submit', function() { var spy = spyOnEvent(document, Pixelated.events.dispatchers.rightPane.openNoMessageSelected); - this.component.select('submitButton').click(); + + this.component.trigger(document, Pixelated.events.feedback.submitted); expect(spy).toHaveBeenTriggeredOn(document); }); }); |