Add unit tests for state_select script

Signed-off-by: marcheing's avatarHeitor Reis <marcheing@gmail.com>
parent 6d491001
state_select = (event) ->
@state_select = (event) ->
$.get(
'/states',
{
......@@ -9,5 +9,5 @@ state_select = (event) ->
$('div#state_select').html(data)
)
$(document).ready(state_select)
$('select#profile_country').on('change', state_select)
$(document).ready(@state_select)
$('select#profile_country').on('change', @state_select)
#= require spec_helper
#= require profiles/state_select
describe 'state_select', ->
before ->
sinon.stub(window, '$')
@get_stub = sinon.stub(window.$, 'get')
$.withArgs('select#profile_country :selected').returns(text: -> 'Brazil')
$.withArgs('#locale').returns(val: -> 'en')
$.withArgs('div#state_select').returns(html: (data) ->)
after ->
$.restore()
it 'is expected to access the state route', ->
@get_stub.withArgs('/states', { country: 'Brazil', locale: 'en' }, (data) -> )
state_select()
sinon.assert.calledOnce(@get_stub)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment