I have a function like this:
function modaldisplayer(){
$('.mymodal').modal('show');
return 'success';
}
Also, I have a function foo which contains modaldisplayer(); in it. I'm using mocha, jest and chai as framework. How can I unit test function foo? Mocha is not seeing .modal('show') as a function.
You should look what a changes $('.mymodal').modal('show'); do in DOM tree. Most likely it takes some elements and toggle some CSS-classes.
Then your testing code can just check this elements and classes like this
expect($('some modal element').hasClass('e.g modal-visible')).toBeTrue();