9
我可以通過這個來找出答案,但我打算使用它。在我的單元測試(qunit)中,我使用asynchShould
(別名asynchTest)測試。部分斷言是等待請求的完成/成功。就像這樣:Ajax請求。哪個回調首先執行完成或成功?
asyncShould('talk to customer list server', 1, function() {
stop(2000);
var forCustomerList = newCustomerListRequest();
forCustomerList.page = 'helpers/helper.php';
forCustomerList.data += '&action=customerListServer&DB=11001';
var originalSuccess = forCustomerList.success;
forCustomerList.success = function(msg) {
if (msg.flash !== undefined && msg.data !== undefined && msg.status !== undefined) {
ok(true, 'json structure correct')
}
else {
ok(false, 'json structure not correct');
}
originalSuccess(msg);
start();
};
testController.getServerData(forCustomerList);
})
我不記得有多少次,我讀過該頁,並沒有看到它。 – Gutzofter 2010-05-29 18:25:51