2016-01-05 144 views
2

我在我的控制器中有代碼行。讓我知道如何爲此編寫茉莉花測試用例?如何在angular Js中編寫ngDialog的jasmine測試用例?

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

這個問題沒有答案? – siri

回答

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(); 
} 

我一直無法測試對話框本身雖然在我的測試運行在任何操作,對話框實際上並沒有彈出!

相關問題