我的控制器中有代码行。让我知道如何为此编写茉莉花测试用例?
if(!angular.element('#reimsave').hasClass("pointerEvent") && !angular.element('#reimedit').is(':visible'))
{
ngDialog.openConfirm({
template: 'app/shared/views/confirmAlert.html',
scope: $scope,
closeByDocument: false,
closeByEscape:false
}).then(function (value) {
intial = slected;
$scope.selectedTab = 'earnings';
$location.path( "/directDeposit/earnings" );
}, function (error) {
});
}
答案 0 :(得分:0)
这取决于您要测试的内容。
一种测试方式可能是......
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();
}
我无法在对话框中测试任何内容,但在我的测试运行器中,对话框实际上并没有弹出!