Angularjs 如何用Js编写ngDialog的jasmine测试用例?
我的控制器中有代码行。让我知道如何为此编写jasmine测试用例Angularjs 如何用Js编写ngDialog的jasmine测试用例?,angularjs,unit-testing,karma-jasmine,Angularjs,Unit Testing,Karma Jasmine,我的控制器中有代码行。让我知道如何为此编写jasmine测试用例 如果(!angular.element('#reimsave').hasClass(“pointerEvent”)和(&!angular.element('#reimedit')是(':visible')) { ngDialog.openConfirm({ 模板:“app/shared/views/confirmAlert.html”, 范围:$scope, closeByDocument:false, closeByEscap
如果(!angular.element('#reimsave').hasClass(“pointerEvent”)和(&!angular.element('#reimedit')是(':visible'))
{
ngDialog.openConfirm({
模板:“app/shared/views/confirmAlert.html”,
范围:$scope,
closeByDocument:false,
closeByEscape:错误
}).然后(函数(值){
初始=选择;
$scope.selectedTab=‘收益’;
$location.path(“/direct存款/收益”);
},函数(错误){
});
}
这取决于您要准确测试的内容
一种测试方法可能是
it("should call ngDialog.openConfirm"), function() {
spyOn(ngDialog, 'openConfirm').and.callThrough();
//include whatever code you need here to meet your if condition
expect(ngDialog.openConfirm).toHaveBeenCalled();
}
我无法在对话框中测试任何东西,尽管与我的测试运行程序一样,对话框实际上不会弹出 这个问题没有答案?