feedback_form_spec.coffee 931 Bytes
Newer Older
1 2 3 4
describe 'FeedbackForm', ->
  beforeEach ->
    loadFixtures 'feedback_form.html'

Prem Sichanugrist committed
5
  describe 'constructor', ->
6
    beforeEach ->
Prem Sichanugrist committed
7
      new FeedbackForm
8
      spyOn($, 'postWithPrefix').andCallFake (url, data, callback, format) ->
9 10 11 12 13 14 15 16 17 18
        callback()

    it 'binds to the #feedback_button', ->
      expect($('#feedback_button')).toHandle 'click'

    it 'post data to /send_feedback on click', ->
      $('#feedback_subject').val 'Awesome!'
      $('#feedback_message').val 'This site is really good.'
      $('#feedback_button').click()

19
      expect($.postWithPrefix).toHaveBeenCalledWith '/send_feedback', {
20 21 22 23 24 25 26 27 28
        subject: 'Awesome!'
        message: 'This site is really good.'
        url: window.location.href
      }, jasmine.any(Function), 'json'

    it 'replace the form with a thank you message', ->
      $('#feedback_button').click()

      expect($('#feedback_div').html()).toEqual 'Feedback submitted. Thank you'