我有一个关于模拟jQuery代码的问题。我使用Jasmine对我的Javascript代码进行单元测试,但无论我使用什么工具,我想知道是否可以模拟加载事件?
我有这个功能:
function Update(arg1,arg2,arg3,arg4) {
// do something with arguments
// push all arguments into an array -> updatedata
$('#' + 'update').load('update.aspx', updatedata, function(response, status, xhr) {
AfterTheUpdate(response, status, xhr)
});
}
我需要在Update函数中模拟加载函数。如果我可以使用所需的值模拟AfterTheUpdate
函数。
这可能吗?
任何人都可以向我提供一些指南/教程,解释如何模拟jQuery加载事件。或者我应该对Update函数进行一些修改以进行模拟吗?