Created
May 24, 2012 18:11
-
-
Save george/2783199 to your computer and use it in GitHub Desktop.
Handling $(document).ready() code in JS unit tests
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery ($) -> | |
$(document).trigger 'content:loaded' | |
$(document).bind 'content:loaded', -> | |
# do stuff |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe 'Foo', -> | |
it 'bars', -> | |
$('#konacha').html(JST['templates/foo']()) | |
$(document).trigger 'content:loaded' | |
# assertions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.