Skip to content

Instantly share code, notes, and snippets.

@george
Created May 24, 2012 18:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save george/2783199 to your computer and use it in GitHub Desktop.
Save george/2783199 to your computer and use it in GitHub Desktop.
Handling $(document).ready() code in JS unit tests
jQuery ($) ->
$(document).trigger 'content:loaded'
$(document).bind 'content:loaded', ->
# do stuff
describe 'Foo', ->
it 'bars', ->
$('#konacha').html(JST['templates/foo']())
$(document).trigger 'content:loaded'
# assertions
@george
Copy link
Author

george commented May 24, 2012

I should probably factor out the template loading and 'content:loaded' calling bits as it's pretty clunky.

If it's not immediately obvious, I'm very new to JS unit testing. All constructive criticism is welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment