开发者

how to test (Jquery) on scroll event in jest

开发者 https://www.devze.com 2022-12-07 17:28 出处:网络
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.

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

精彩评论

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

关注公众号