我正在使用jasmine 2.0来测试javascript函数。
$scope.onReturnDateChange=function(){
if($scope.details.returndate){
if($scope.details.id='Inquiry'||$scope.details.amount=''){
return
}
}
}
答案 0 :(得分:0)
你必须为此目的使用间谍
首先,您需要添加控制器
var $ controller;
beforeEach(inject(function(_$controller_){
// The injector unwraps the underscores (_) from around the parameter names when matching
$controller = _$controller_;
}));
it('test',function(){
var $scope = {};
var controller = $controller('Controller_name', { $scope: $scope });
spyOn($scope,'onReturnDateChange')
$scope.onReturnDateChange();
expect();
})