I need help working with toBeHidden() and toBeVisible() jQuery-Jasmine methods.
When the user checks the checkbox, the text box should slide down - and uncheck its slides. The text box is hidden when the page loads.
The code works fine in my application, but I am confused by the result that I get in my tests.
The first two work - checking if the field is hidden by default and visible on the first change:
expect($('#text-field')).toBeHidden(); // passes $('#checkbox').prop('checked', true).change(); expect($('#text-field')).toBeVisible(); // passes
But when the checkbox is unchecked, the text field is smoothed in the real version, but it does not execute in my test:
$('#checkbox').prop('checked', false).change(); expect($('#text-field')).toBeHidden();
I also tried:
expect($('#text-field')).not.toBeVisible(); // fails expect($('#text-field')).toHaveCss({display: "none"}); // fails
Does anyone know what I'm doing wrong, or know what else I need to do to help Jasmine see that the text field has shifted?
source share