0
내 지시선 컨트롤러에 함수가 있는데 테스트를 시도하고 어떤 리소스도 찾을 수 없습니다. 나는이 오류 형식 오류를 던지고 각지시어 컨트롤러 기능을 테스트하는 방법은 무엇입니까?
before each {
scope = $rootScope ;
$compile(element)(scope);
scope.$digest();
}
it('should update days when datepicker is changed', function() {
scope.seldate = new Date('4/11/2014');
scope.stdate = new Date('4/1/2014');
scop`enter code here`e.days = 10;
scope.$digest();
scope.$apply(function() {
scope.seldate = new Date('4/12/2014');
scope.datePickerChange(); // This is a function in my directive controller
});
expect(scope.days).toBe(11);
});
app.directive('mydirective',function(){
return {
restrict:'E',
scope:{
days: '=',
selectedDate: '=',
startDate: '='
},
$scope.datePickerChange = function() {
//Sod is helper for start of the day with hours/mins/seconds set to 0
$scope.days = moment(new Date($scope.selectedDate)).sod().diff($scope.getStartDate(), 'days');
};
};
});
전에이 : 그 너머
app.directive('mydirective',function(){
return {
restrict:'E',
scope:{
days: '=',
selectedDate: '=',
startDate: '='
},
link: function(scope, elem, attrs) {
scope.datePickerChange = function() {
//Sod is helper for start of the day with hours/mins/seconds set to 0
scope.days = moment(new Date($scope.selectedDate))
.sod().diff($scope.getStartDate(), 'days');
};
}
}
});
당신의 지시를 테스트하기 : 개체 번호가있는 방법 'datePickerChange'