How do you test document.ready block using Jasmine? To be more specific , if I have a block like this :
$(document).ready(
function () {
abc = true;
}
});
How do you test that the inner function was called when the document was ready, using Jasmine?
You could refactor your code to be something like this:
var onReady = function(){
abc = true;
}
$(document).ready(onReady);
and your tests:
it("Tests abc", function() {
onReady() ;
expect(tesabctVar).toEqual(true);
});
How do you test document.ready block using Jasmine? To be more specific , > if I have a block like this :
$(document).ready( function(){ abc= true; } );
My understanding is that code you have written within $(document).ready closure above is not testable. This link has a good explanation of how to make it more testable : http://bittersweetryan.github.io/jasmine-presentation/#slide-17
How do you test that the inner function was called when the document was ready, using Jasmine?
Answered above by m59 in comment already.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With