使用 QUnit 如何测试 window.scroll 事件?在下面的代码中,我正在触发事件,但这(据我所知)被放入事件队列中。下一行中的 ok
断言在调用事件回调之前执行。如何测试此类事件?
test("should attach panel once window scrolled down past certain point", function() {
$(window).scrollTop(1110); // puts event in a queue I believe and next line is executed before this scroll event callback
ok(LozengesPanel.panel.hasClass("fixed"),"lozenges panel is sticky");
});
最佳答案
尝试 Qunit 的异步回调。
关于javascript - 如何编写 QUnit 测试来测试事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22032866/