我是 jasmine 的新手,并使用 angularjs 作为框架。我如何测试$(window).trigger
“haveBeenCalledWith”:
要测试的代码(它是 angularjs 服务中的一个函数):
start: function (serverUrl, callbackFunc) {
// initialize communication manager and when ready start the worklist server
commManager.initAsync(serverUrl, function (isConnected) {
if (isConnected) {
var msgHeader = new protocolMessageHeader(userSessionGuid, messageCommandName.START_WL_SESSION + "_RQ");
var dataSet = { $type: 10, UserSessionGuid: userSessionGuid, WLSessionGuid: wlSessionGuid };
commManager.sendMessage(new protocolMessage(msgHeader, dataSet), function (data) {
if (callbackFunc) {
callbackFunc(data);
}
});
} else {
**$(window).trigger(events.onShowModalDialog, {
title: "Worklist Server Error",
body: "Can not establish connection to Worklist server",
type: generalStatusEnum.ERROR
});**
}
});
}
我做isConnected
了假,我想测试$(window).trigger
用上述参数调用的