使用 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 的异步回调。
检查这个 - http://qunitjs.com/cookbook/#asynchronous-callbacks