我有jQuery代码,当我点击一个链接它首先皮上,然后删除一些HTML,像这样:即确保在QUnit等待测试
$(this).parent().parent().hide('slow', function() {
$(this).remove();
});
我想打一个QUnit测试的HTML在问题被删除:
$(thelink).click();
// Check that it is gone, by finding the first item in the list
entity = input.form.find('.recurrenceinput_occurrences .occurrence span.action a')[0];
// And make sure it's NOT the deleted one:
ok(entity.attributes.date.value !== "20110413T000000");
问题是隐藏动画已经运行结束之前确定()运行测试,当然,这样的offenting HTML尚未拆除,并导致测试失败。
我试过各种方式延迟/停止测试一秒左右,但似乎没有工作。最明显的一个就是用asynTest做
stop();
setTimeout(start, 2000);
但是这并没有真正阻止测试。它似乎停止东西两秒钟,但我不知道是什么。 :-)
任何想法?
宾果!这是事情的正确顺序。 :-)所以stop()实际上只停止了测试的结束? –
此方法已被弃用(http://qunitjs.com/upgrade-guide-2.x/#replace-stop-and-start-with-assert-async)。 @ ekcrisp的答案使用了新的方法。 – Joe
6年前提出的问题已被弃用,这令人感到惊讶。大声笑 – epascarello