I am calling $(window).on('scroll', () => { the method in my js file. But I can't find out how to test this method using JEST.
The complete code is below:
$(document).ready(() => {
$(window).on('scroll', () => {
var scrollPos = $(window)开发者_如何学Go.scrollTop();
var pagesection = ($('.pagesection-meet').offset().top);
var height = ($('.pagesection-meet').height());
if(scrollPos >= pagesection + height || scrollPos < pagesection)
$('.meet-nav-header').removeClass('sticky');
else
$('.meet-nav-header').addClass('sticky');
});
});
How may I test if and else conditions also?
精彩评论