I am very beginner in jasmine. I dont Know how to test this following jquery code using jasmine.
if ($('.data-block').length > 0) {
$('.span4:even', '.data-block').addClass('even');
$('.span4:odd', '.data-block').addClass('odd');
}
Can you tell me how i write the testing code using jasmine for about this jquery program. Thank you for your answer.
You can use Jasmine-JQuery plugin and test against an injected DOM:
https://github.com/velesin/jasmine-jquery
The plugin provides custom matchers such as:
expect($('.span4:even')).toHaveAttr('class', 'even')
Ps Here you have a short introduction.
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