我正在尝试测试 jquery ajax 请求
Widget.seriesEditLoadSeriesAjax = function( id , jqXHRCallbacks ) {
var ajax_url = '/dashboard/charts/ajax/2';
var data_obj = {
SID : id || 0 ,
getSeries : true
};
var jqxhr = $.ajax({
url : ajax_url,
type : "GET",
data : data_obj
});
jqXHRCallbacks = jqXHRCallbacks || {
done : Widget.seriesEditLoadSeriesCallback ,
always : function(){
$('#series_loader').hide();
}
};
jQuery.extend( jqxhr, jqXHRCallbacks );
console.log( 'jqxhr.always', jqxhr.always );
console.log( 'jqxhr.done', jqxhr.done );
}
并使用 qUnit 库为它编写了一个测试
test( "Widget.seriesEditLoadSeriesAjax", function() {
stop();
Widget.seriesEditLoadSeriesAjax( 67,{
done : function(){
ok( true, "asynchronous Success !");
start();
} ,
always : function(){
ok(true, "asynchronous completed PASS!");
start();
}
});
});
但它总是返回结果
asynchronous completed PASS!
为什么它省略了测试done
。请帮忙 !