I am trying to use a function I have defined in a JS file within my Jasmine test, but it is coming back as undefined when I run the test.
At the top of my spec I am requiring the coffee file I am using, would that then give me access to the contents of the JS? Could I then not use the function within my test?
employer_category.coffee
$(document).ready ->
toggle_glyphicon_plus_minus
toggle_glyphicon_plus_minus = () ->
$('#govt_category').click ->
$('#govt_category_span').toggleClass('glyphicon-plus glyphicon-minus')
$('#federal_category').click ->
$('#federal_category_span').toggleClass('glyphicon-plus glyphicon-minus')
$('#other_category').click ->
$('#other_category_span').toggleClass('glyphicon-plus glyphicon-minus')
employe_category_spec.coffee
#= require employer_category
describe 'accordion functionality', ->
beforeEach ->
employer_category = "<h5 id='govt_category'></h5>" + "<span id='govt_category_span' class='glyphicon glyphicon-plus'>"
$(employer_category).appendTo('body')
$('#govt_category').trigger('click')
it 'should invoke a click event on govt_category', ->
toggle_glyphicon_plus_minus
expect($('#govt_category_span')).toHaveClass('glyphicon-minus')