开发者

how to test (Jquery) on scroll event in jest

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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜