');
- $scope.ngModelOptions = angular.copy(ngModelOptions);
- $scope.ngModelOptions.timezone = null;
- if ($scope.ngModelOptions.updateOnDefault === true) {
- $scope.ngModelOptions.updateOn = $scope.ngModelOptions.updateOn ?
- $scope.ngModelOptions.updateOn + ' default' : 'default';
+ if (ngModelOptions) {
+ timezone = ngModelOptions.timezone;
+ $scope.ngModelOptions = angular.copy(ngModelOptions);
+ $scope.ngModelOptions.timezone = null;
+ if ($scope.ngModelOptions.updateOnDefault === true) {
+ $scope.ngModelOptions.updateOn = $scope.ngModelOptions.updateOn ?
+ $scope.ngModelOptions.updateOn + ' default' : 'default';
+ }
+
+ popupEl.attr('ng-model-options', 'ngModelOptions');
+ } else {
+ timezone = null;
}
popupEl.attr({
'ng-model': 'date',
- 'ng-model-options': 'ngModelOptions',
'ng-change': 'dateSelection(date)',
'template-url': datepickerPopupTemplateUrl
});
@@ -849,98 +743,18 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
datepickerEl = angular.element(popupEl.children()[0]);
datepickerEl.attr('template-url', datepickerTemplateUrl);
- if (isHtml5DateInput) {
- if ($attrs.type === 'month') {
- datepickerEl.attr('datepicker-mode', '"month"');
- datepickerEl.attr('min-mode', 'month');
- }
- }
-
- if ($scope.datepickerOptions) {
- datepickerEl.attr('datepicker-options', 'datepickerOptions');
+ if (!$scope.datepickerOptions) {
+ $scope.datepickerOptions = {};
}
- angular.forEach(['minMode', 'maxMode', 'datepickerMode', 'shortcutPropagation'], function(key) {
- if ($attrs[key]) {
- if (datepickerPopupAttributeWarning) {
- $log.warn('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- }
-
- var getAttribute = $parse($attrs[key]);
- var propConfig = {
- get: function() {
- return getAttribute($scope.$parent);
- }
- };
-
- datepickerEl.attr(cameltoDash(key), 'watchData.' + key);
-
- // Propagate changes from datepicker to outside
- if (key === 'datepickerMode') {
- var setAttribute = getAttribute.assign;
- propConfig.set = function(v) {
- setAttribute($scope.$parent, v);
- };
- }
-
- Object.defineProperty($scope.watchData, key, propConfig);
- }
- });
-
- angular.forEach(['minDate', 'maxDate', 'initDate'], function(key) {
- if ($attrs[key]) {
- if (datepickerPopupAttributeWarning) {
- $log.warn('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- }
-
- var getAttribute = $parse($attrs[key]);
-
- watchListeners.push($scope.$parent.$watch(getAttribute, function(value) {
- if (key === 'minDate' || key === 'maxDate') {
- if (value === null) {
- cache[key] = null;
- } else if (angular.isDate(value)) {
- cache[key] = dateParser.fromTimezone(new Date(value), ngModelOptions.timezone);
- } else {
- cache[key] = new Date(dateFilter(value, 'medium'));
- }
-
- $scope.watchData[key] = value === null ? null : cache[key];
- } else {
- var date = value ? new Date(value) : new Date();
- $scope.watchData[key] = dateParser.fromTimezone(date, ngModelOptions.timezone);
- }
- }));
-
- datepickerEl.attr(cameltoDash(key), 'watchData.' + key);
- }
- });
-
- if ($attrs.dateDisabled) {
- if (datepickerPopupAttributeWarning) {
- $log.warn('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
+ if (isHtml5DateInput) {
+ if ($attrs.type === 'month') {
+ $scope.datepickerOptions.datepickerMode = 'month';
+ $scope.datepickerOptions.minMode = 'month';
}
-
- datepickerEl.attr('date-disabled', 'dateDisabled({ date: date, mode: mode })');
}
- angular.forEach(['formatDay', 'formatMonth', 'formatYear', 'formatDayHeader', 'formatDayTitle', 'formatMonthTitle', 'showWeeks', 'startingDay', 'yearRows', 'yearColumns'], function(key) {
- if (angular.isDefined($attrs[key])) {
- if (datepickerPopupAttributeWarning) {
- $log.warn('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- }
-
- datepickerEl.attr(cameltoDash(key), $attrs[key]);
- }
- });
-
- if ($attrs.customClass) {
- if (datepickerPopupAttributeWarning) {
- $log.warn('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- }
-
- datepickerEl.attr('custom-class', 'customClass({ date: date, mode: mode })');
- }
+ datepickerEl.attr('datepicker-options', 'datepickerOptions');
if (!isHtml5DateInput) {
// Internal API to maintain the correct ng-invalid-[key] class
@@ -953,7 +767,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
return value;
}
- $scope.date = dateParser.fromTimezone(value, ngModelOptions.timezone);
+ $scope.date = dateParser.fromTimezone(value, timezone);
if (angular.isNumber($scope.date)) {
$scope.date = new Date($scope.date);
@@ -963,7 +777,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
});
} else {
ngModel.$formatters.push(function(value) {
- $scope.date = dateParser.fromTimezone(value, ngModelOptions.timezone);
+ $scope.date = dateParser.fromTimezone(value, timezone);
return value;
});
}
@@ -1015,17 +829,23 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
$scope.isDisabled = function(date) {
if (date === 'today') {
- date = dateParser.fromTimezone(new Date(), ngModelOptions.timezone);
+ date = dateParser.fromTimezone(new Date(), timezone);
}
- if ($scope.datepickerOptions) {
- return $scope.datepickerOptions &&
- $scope.datepickerOptions.minDate && $scope.compare(date, $scope.datepickerOptions.minDate) < 0 ||
- $scope.datepickerOptions.maxDate && $scope.compare(date, $scope.datepickerOptions.maxDate) > 0;
- }
+ var dates = {};
+ angular.forEach(['minDate', 'maxDate'], function(key) {
+ if ($scope.datepickerOptions[key] === null) {
+ dates[key] = null;
+ } else if (angular.isDate($scope.datepickerOptions[key])) {
+ dates[key] = dateParser.fromTimezone(new Date($scope.datepickerOptions[key]), timezone);
+ } else {
+ dates[key] = new Date(dateFilter($scope.datepickerOptions[key], 'medium'));
+ }
+ });
- return $scope.watchData.minDate && $scope.compare(date, cache.minDate) < 0 ||
- $scope.watchData.maxDate && $scope.compare(date, cache.maxDate) > 0;
+ return $scope.datepickerOptions &&
+ dates.minDate && $scope.compare(date, dates.minDate) < 0 ||
+ dates.maxDate && $scope.compare(date, dates.maxDate) > 0;
};
$scope.compare = function(date1, date2) {
@@ -1093,6 +913,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
if (onOpenFocus) {
$scope.$broadcast('uib:datepicker.focus');
}
+
$document.on('click', documentClickBind);
var placement = $attrs.popupPlacement ? $attrs.popupPlacement : datepickerPopupConfig.placement;
@@ -1153,7 +974,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
if (angular.isString(viewValue)) {
var date = parseDateString(viewValue);
if (!isNaN(date)) {
- return dateParser.toTimezone(date, ngModelOptions.timezone);
+ return dateParser.toTimezone(date, timezone);
}
}
@@ -1246,9 +1067,7 @@ function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $
isOpen: '=?',
currentText: '@',
clearText: '@',
- closeText: '@',
- dateDisabled: '&',
- customClass: '&'
+ closeText: '@'
},
link: function(scope, element, attrs, ctrls) {
var ngModel = ctrls[0],
diff --git a/src/datepicker/test/datepicker.spec.js b/src/datepicker/test/datepicker.spec.js
index 76f55911d3..77f9e6e41b 100644
--- a/src/datepicker/test/datepicker.spec.js
+++ b/src/datepicker/test/datepicker.spec.js
@@ -205,1406 +205,6 @@ describe('datepicker', function() {
});
});
- // TODO: Remove on next minor release
- describe('uibDatepickerAttributeWarning', function() {
- var $compile,
- $log,
- $scope;
-
- it('should not log warning for datepickerOptions usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.opts = {};
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for customClass attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date(),
- customClass: 'none'
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker customClass attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for customClass attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date(),
- customClass: 'none'
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for dateDisabled attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date(),
- dateDisabled: false
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker dateDisabled attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for dateDisabled attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date(),
- dateDisabled: false
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for datepickerMode attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date(),
- mode: 'day'
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker datepickerMode attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for datepickerMode attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date(),
- mode: 'day'
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatDay attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker formatDay attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatDay attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatMonth attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker formatMonth attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatMonth attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatYear attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker formatYear attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatYear attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatDayHeader attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker formatDayHeader attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatDayHeader attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatDayTitle attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker formatDayTitle attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatDayTitle attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatMonthTitle attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker formatMonthTitle attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatMonthTitle attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for showWeeks attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker showWeeks attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for showWeeks attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for shortcutPropagation attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker shortcutPropagation attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for shortcutPropagation attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for yearColumns attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker yearColumns attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for yearColumns attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for yearRows attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker yearRows attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for yearRows attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for minDate attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
- $scope.minDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker minDate attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for minDate attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
- $scope.minDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for maxDate attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
- $scope.maxDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker maxDate attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for maxDate attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
- $scope.maxDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for minMode attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker minMode attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for minMode attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for maxMode attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker maxMode attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for maxMode attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for initDate attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
- $scope.initDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker initDate attribute usage is deprecated, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for initDate attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.locals = {
- date: new Date()
- };
- $scope.initDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
- });
-
- // TODO: Remove on next minor release
- describe('uibDatepickerPopupAttributeWarning', function() {
- var $compile,
- $log,
- $scope;
-
- it('should not log warning for datepickerOptions usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
- $scope.opts = {};
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for customClass attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for customClass attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for dateDisabled attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for dateDisabled attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for minMode attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for minMode attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for maxMode attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for maxMode attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for shortcutPropagation attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for shortcutPropagation attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for minDate attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
- $scope.minDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for minDate attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
- $scope.minDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for maxDate attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
- $scope.maxDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for maxDate attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
- $scope.maxDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for initDate attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
- $scope.initDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for initDate attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
- $scope.initDate = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatDay attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatDay attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatMonth attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatMonth attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatYear attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatYear attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatDayHeader attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatDayHeader attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatDayTitle attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatDayTitle attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for formatMonthTitle attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for formatMonthTitle attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for showWeeks attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for showWeeks attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for startingDay attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for startingDay attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for yearColumns attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for yearColumns attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
-
- it('should log warning for yearRows attribute usage', function() {
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).toHaveBeenCalledWith('uib-datepicker settings via uib-datepicker-popup attributes are deprecated and will be removed in UI Bootstrap 1.3, use datepicker-options attribute instead');
- });
-
- it('should suppress warning for yearRows attribute usage', function() {
- module(function($provide) {
- $provide.value('uibDatepickerPopupAttributeWarning', false);
- });
- inject(function(_$log_, _$rootScope_, _$compile_) {
- $log = _$log_;
- $scope = _$rootScope_.$new();
- $compile = _$compile_;
- });
-
- $scope.date = new Date();
-
- spyOn($log, 'warn');
- element = $compile('')($scope);
- $scope.$digest();
-
- expect($log.warn).not.toHaveBeenCalled();
- });
- });
-
describe('', function() {
beforeEach(inject(function(_$compile_, _$rootScope_, _$templateCache_) {
$compile = _$compile_;
@@ -2276,10 +876,10 @@ describe('datepicker', function() {
describe('attribute `datepicker-options`', function() {
describe('startingDay', function() {
beforeEach(function() {
- $rootScope.datepickerOptions = {
+ $rootScope.options = {
startingDay: 1
};
- element = $compile('')($rootScope);
+ element = $compile('')($rootScope);
$rootScope.$digest();
});
@@ -2305,10 +905,10 @@ describe('datepicker', function() {
describe('showWeeks', function() {
beforeEach(function() {
- $rootScope.datepickerOptions = {
+ $rootScope.options = {
showWeeks: false
};
- element = $compile('')($rootScope);
+ element = $compile('')($rootScope);
$rootScope.$digest();
});
@@ -2321,151 +921,53 @@ describe('datepicker', function() {
});
});
- describe('minDate', function() {
- beforeEach(function() {
- $rootScope.datepickerOptions = {
- minDate: new Date('September 12, 2010')
- };
- element = $compile('')($rootScope);
- $rootScope.$digest();
- });
-
- it('disables appropriate days in current month', function() {
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index < 14);
- });
- });
-
- it('disables appropriate days when min date changes', function() {
- $rootScope.datepickerOptions.minDate = new Date('September 5, 2010');
- $rootScope.$digest();
-
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index < 7);
- });
- });
-
- it('invalidates when model is a disabled date', function() {
- $rootScope.datepickerOptions.minDate = new Date('September 5, 2010');
- $rootScope.date = new Date('September 2, 2010');
- $rootScope.$digest();
- expect(element.hasClass('ng-invalid')).toBeTruthy();
- expect(element.hasClass('ng-invalid-date-disabled')).toBeTruthy();
- });
-
- it('disables all days in previous month', function() {
- clickPreviousButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(true);
- });
- });
-
- it('disables no days in next month', function() {
- clickNextButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
- });
- });
-
- it('disables appropriate months in current year', function() {
- clickTitleButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index < 8);
- });
- });
-
- it('disables all months in previous year', function() {
- clickTitleButton();
- clickPreviousButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(true);
- });
- });
-
- it('disables no months in next year', function() {
- clickTitleButton();
- clickNextButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
- });
- });
-
- it('enables everything before if it is cleared', function() {
- $rootScope.datepickerOptions.minDate = null;
- $rootScope.date = new Date('December 20, 1949');
- $rootScope.$digest();
-
- clickTitleButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
- });
- });
-
- it('accepts literals, \'yyyy-MM-dd\' case', function() {
- $rootScope.datepickerOptions.minDate = '2010-09-05';
- element = $compile('')($rootScope);
- $rootScope.$digest();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index < 7);
- });
- });
- });
-
- describe('maxDate', function() {
+ describe('minDate', function() {
beforeEach(function() {
- $rootScope.datepickerOptions = {
- maxDate: new Date('September 25, 2010')
+ $rootScope.options = {
+ minDate: new Date('September 12, 2010')
};
- element = $compile('')($rootScope);
+ element = $compile('')($rootScope);
$rootScope.$digest();
});
it('disables appropriate days in current month', function() {
var buttons = getAllOptionsEl();
angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index > 27);
+ expect(angular.element(button).prop('disabled')).toBe(index < 14);
});
});
- it('disables appropriate days when max date changes', function() {
- $rootScope.datepickerOptions.maxDate = new Date('September 18, 2010');
+ it('disables appropriate days when min date changes', function() {
+ $rootScope.options.minDate = new Date('September 5, 2010');
$rootScope.$digest();
var buttons = getAllOptionsEl();
angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index > 20);
+ expect(angular.element(button).prop('disabled')).toBe(index < 7);
});
});
it('invalidates when model is a disabled date', function() {
- $rootScope.datepickerOptions.maxDate = new Date('September 18, 2010');
+ $rootScope.options.minDate = new Date('September 5, 2010');
+ $rootScope.date = new Date('September 2, 2010');
$rootScope.$digest();
expect(element.hasClass('ng-invalid')).toBeTruthy();
expect(element.hasClass('ng-invalid-date-disabled')).toBeTruthy();
});
- it('disables no days in previous month', function() {
+ it('disables all days in previous month', function() {
clickPreviousButton();
var buttons = getAllOptionsEl();
angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
+ expect(angular.element(button).prop('disabled')).toBe(true);
});
});
- it('disables all days in next month', function() {
+ it('disables no days in next month', function() {
clickNextButton();
var buttons = getAllOptionsEl();
angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(true);
+ expect(angular.element(button).prop('disabled')).toBe(false);
});
});
@@ -2473,464 +975,195 @@ describe('datepicker', function() {
clickTitleButton();
var buttons = getAllOptionsEl();
angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index > 8);
+ expect(angular.element(button).prop('disabled')).toBe(index < 8);
});
});
- it('disables no months in previous year', function() {
+ it('disables all months in previous year', function() {
clickTitleButton();
clickPreviousButton();
var buttons = getAllOptionsEl();
angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
+ expect(angular.element(button).prop('disabled')).toBe(true);
});
});
- it('disables all months in next year', function() {
+ it('disables no months in next year', function() {
clickTitleButton();
clickNextButton();
var buttons = getAllOptionsEl();
angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(true);
+ expect(angular.element(button).prop('disabled')).toBe(false);
});
});
- it('enables everything after if it is cleared', function() {
- $rootScope.datepickerOptions.maxDate = null;
+ it('enables everything before if it is cleared', function() {
+ $rootScope.options.minDate = null;
+ $rootScope.date = new Date('December 20, 1949');
$rootScope.$digest();
+
+ clickTitleButton();
var buttons = getAllOptionsEl();
angular.forEach(buttons, function(button, index) {
expect(angular.element(button).prop('disabled')).toBe(false);
});
});
- });
- describe('formatting', function() {
- beforeEach(function() {
- $rootScope.datepickerOptions = {
- formatDay: 'd',
- formatDayHeader: 'EEEE',
- formatDayTitle: 'MMMM, yy',
- formatMonth: 'MMM',
- formatMonthTitle: 'yy',
- formatYear: 'yy',
- yearColumns: 4,
- yearRows: 3
- };
- element = $compile('')($rootScope);
+ it('accepts literals, \'yyyy-MM-dd\' case', function() {
+ $rootScope.options.minDate = '2010-09-05';
+ element = $compile('')($rootScope);
$rootScope.$digest();
+ var buttons = getAllOptionsEl();
+ angular.forEach(buttons, function(button, index) {
+ expect(angular.element(button).prop('disabled')).toBe(index < 7);
+ });
});
-
- it('changes the title format in `day` mode', function() {
- expect(getTitle()).toBe('September, 10');
- });
-
- it('changes the title & months format in `month` mode', function() {
- clickTitleButton();
-
- expect(getTitle()).toBe('10');
- expect(getOptions()).toEqual([
- ['Jan', 'Feb', 'Mar'],
- ['Apr', 'May', 'Jun'],
- ['Jul', 'Aug', 'Sep'],
- ['Oct', 'Nov', 'Dec']
- ]);
- });
-
- it('changes the title, year format & range in `year` mode', function() {
- clickTitleButton();
- clickTitleButton();
-
- expect(getTitle()).toBe('05 - 16');
- expect(getOptions()).toEqual([
- ['05', '06', '07', '08'],
- ['09', '10', '11', '12'],
- ['13', '14', '15', '16']
- ]);
- });
-
- it('shows day labels', function() {
- expect(getLabels(true)).toEqual(['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']);
- });
-
- it('changes the day format', function() {
- expect(getOptions(true)).toEqual([
- ['29', '30', '31', '1', '2', '3', '4'],
- ['5', '6', '7', '8', '9', '10', '11'],
- ['12', '13', '14', '15', '16', '17', '18'],
- ['19', '20', '21', '22', '23', '24', '25'],
- ['26', '27', '28', '29', '30', '1', '2'],
- ['3', '4', '5', '6', '7', '8', '9']
- ]);
- });
- });
- });
-
- describe('attribute `starting-day`', function() {
- beforeEach(function() {
- $rootScope.startingDay = 1;
- element = $compile('')($rootScope);
- $rootScope.$digest();
- });
-
- it('shows the day labels rotated', function() {
- expect(getLabels(true)).toEqual(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']);
- });
-
- it('renders the calendar days correctly', function() {
- expect(getOptions(true)).toEqual([
- ['30', '31', '01', '02', '03', '04', '05'],
- ['06', '07', '08', '09', '10', '11', '12'],
- ['13', '14', '15', '16', '17', '18', '19'],
- ['20', '21', '22', '23', '24', '25', '26'],
- ['27', '28', '29', '30', '01', '02', '03'],
- ['04', '05', '06', '07', '08', '09', '10']
- ]);
- });
-
- it('renders the week numbers correctly', function() {
- expect(getWeeks()).toEqual(['35', '36', '37', '38', '39', '40']);
- });
- });
-
- describe('attribute `show-weeks`', function() {
- beforeEach(function() {
- $rootScope.showWeeks = false;
- element = $compile('')($rootScope);
- $rootScope.$digest();
- });
-
- it('hides week numbers based on variable', function() {
- expect(getLabelsRow().find('th').length).toEqual(7);
- var tr = element.find('tbody').find('tr');
- for (var i = 0; i < 5; i++) {
- expect(tr.eq(i).find('td').length).toEqual(7);
- }
- });
- });
-
- describe('`min-date` attribute', function() {
- beforeEach(function() {
- $rootScope.mindate = new Date('September 12, 2010');
- element = $compile('')($rootScope);
- $rootScope.$digest();
- });
-
- it('disables appropriate days in current month', function() {
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index < 14);
- });
- });
-
- it('disables appropriate days when min date changes', function() {
- $rootScope.mindate = new Date('September 5, 2010');
- $rootScope.$digest();
-
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index < 7);
- });
- });
-
- it('invalidates when model is a disabled date', function() {
- $rootScope.mindate = new Date('September 5, 2010');
- $rootScope.date = new Date('September 2, 2010');
- $rootScope.$digest();
- expect(element.hasClass('ng-invalid')).toBeTruthy();
- expect(element.hasClass('ng-invalid-date-disabled')).toBeTruthy();
- });
-
- it('disables all days in previous month', function() {
- clickPreviousButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(true);
- });
- });
-
- it('disables no days in next month', function() {
- clickNextButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
- });
- });
-
- it('disables appropriate months in current year', function() {
- clickTitleButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index < 8);
- });
- });
-
- it('disables all months in previous year', function() {
- clickTitleButton();
- clickPreviousButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(true);
- });
- });
-
- it('disables no months in next year', function() {
- clickTitleButton();
- clickNextButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
- });
- });
-
- it('enables everything before if it is cleared', function() {
- $rootScope.mindate = null;
- $rootScope.date = new Date('December 20, 1949');
- $rootScope.$digest();
-
- clickTitleButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
- });
- });
-
- it('accepts literals, \'yyyy-MM-dd\' case', function() {
- element = $compile('')($rootScope);
- $rootScope.$digest();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index < 7);
- });
- });
- });
-
- describe('`max-date` attribute', function() {
- beforeEach(function() {
- $rootScope.maxdate = new Date('September 25, 2010');
- element = $compile('')($rootScope);
- $rootScope.$digest();
- });
-
- it('disables appropriate days in current month', function() {
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index > 27);
- });
- });
-
- it('disables appropriate days when max date changes', function() {
- $rootScope.maxdate = new Date('September 18, 2010');
- $rootScope.$digest();
-
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index > 20);
- });
- });
-
- it('invalidates when model is a disabled date', function() {
- $rootScope.maxdate = new Date('September 18, 2010');
- $rootScope.$digest();
- expect(element.hasClass('ng-invalid')).toBeTruthy();
- expect(element.hasClass('ng-invalid-date-disabled')).toBeTruthy();
- });
-
- it('disables no days in previous month', function() {
- clickPreviousButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
- });
- });
-
- it('disables all days in next month', function() {
- clickNextButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(true);
- });
- });
-
- it('disables appropriate months in current year', function() {
- clickTitleButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(index > 8);
- });
- });
-
- it('disables no months in previous year', function() {
- clickTitleButton();
- clickPreviousButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
- });
- });
-
- it('disables all months in next year', function() {
- clickTitleButton();
- clickNextButton();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(true);
- });
- });
-
- it('enables everything after if it is cleared', function() {
- $rootScope.maxdate = null;
- $rootScope.$digest();
- var buttons = getAllOptionsEl();
- angular.forEach(buttons, function(button, index) {
- expect(angular.element(button).prop('disabled')).toBe(false);
- });
- });
- });
-
- describe('date-disabled expression', function() {
- beforeEach(function() {
- $rootScope.options = {
- dateDisabled: jasmine.createSpy('dateDisabled')
- };
- element = $compile('')($rootScope);
- $rootScope.$digest();
});
- it('executes the dateDisabled expression for each visible day plus one for validation', function() {
- expect($rootScope.options.dateDisabled.calls.count()).toEqual(42 + 1);
- });
+ describe('maxDate', function() {
+ beforeEach(function() {
+ $rootScope.options = {
+ maxDate: new Date('September 25, 2010')
+ };
+ element = $compile('')($rootScope);
+ $rootScope.$digest();
+ });
- it('executes the dateDisabled expression for each visible month plus one for validation', function() {
- $rootScope.options.dateDisabled.calls.reset();
- clickTitleButton();
- expect($rootScope.options.dateDisabled.calls.count()).toEqual(12 + 1);
- });
+ it('disables appropriate days in current month', function() {
+ var buttons = getAllOptionsEl();
+ angular.forEach(buttons, function(button, index) {
+ expect(angular.element(button).prop('disabled')).toBe(index > 27);
+ });
+ });
- it('executes the dateDisabled expression for each visible year plus one for validation', function() {
- clickTitleButton();
- $rootScope.options.dateDisabled.calls.reset();
- clickTitleButton();
- expect($rootScope.options.dateDisabled.calls.count()).toEqual(20 + 1);
- });
- });
+ it('disables appropriate days when max date changes', function() {
+ $rootScope.options.maxDate = new Date('September 18, 2010');
+ $rootScope.$digest();
- describe('custom-class expression', function() {
- beforeEach(function() {
- $rootScope.options = {
- customClass: jasmine.createSpy('customClass')
- };
- element = $compile('')($rootScope);
- $rootScope.$digest();
- });
+ var buttons = getAllOptionsEl();
+ angular.forEach(buttons, function(button, index) {
+ expect(angular.element(button).prop('disabled')).toBe(index > 20);
+ });
+ });
- it('executes the customClass expression for each visible day plus one for validation', function() {
- expect($rootScope.options.customClass.calls.count()).toEqual(42);
- });
+ it('invalidates when model is a disabled date', function() {
+ $rootScope.options.maxDate = new Date('September 18, 2010');
+ $rootScope.$digest();
+ expect(element.hasClass('ng-invalid')).toBeTruthy();
+ expect(element.hasClass('ng-invalid-date-disabled')).toBeTruthy();
+ });
- it('executes the customClass expression for each visible month plus one for validation', function() {
- $rootScope.options.customClass.calls.reset();
- clickTitleButton();
- expect($rootScope.options.customClass.calls.count()).toEqual(12);
- });
+ it('disables no days in previous month', function() {
+ clickPreviousButton();
+ var buttons = getAllOptionsEl();
+ angular.forEach(buttons, function(button, index) {
+ expect(angular.element(button).prop('disabled')).toBe(false);
+ });
+ });
- it('executes the customClass expression for each visible year plus one for validation', function() {
- clickTitleButton();
- $rootScope.options.customClass.calls.reset();
- clickTitleButton();
- expect($rootScope.options.customClass.calls.count()).toEqual(20);
- });
- });
+ it('disables all days in next month', function() {
+ clickNextButton();
+ var buttons = getAllOptionsEl();
+ angular.forEach(buttons, function(button, index) {
+ expect(angular.element(button).prop('disabled')).toBe(true);
+ });
+ });
- describe('formatting', function() {
- beforeEach(function() {
- $rootScope.dayTitle = 'MMMM, yy';
- element = $compile('')($rootScope);
- $rootScope.$digest();
- });
+ it('disables appropriate months in current year', function() {
+ clickTitleButton();
+ var buttons = getAllOptionsEl();
+ angular.forEach(buttons, function(button, index) {
+ expect(angular.element(button).prop('disabled')).toBe(index > 8);
+ });
+ });
- it('changes the title format in `day` mode', function() {
- expect(getTitle()).toBe('September, 10');
- });
+ it('disables no months in previous year', function() {
+ clickTitleButton();
+ clickPreviousButton();
+ var buttons = getAllOptionsEl();
+ angular.forEach(buttons, function(button, index) {
+ expect(angular.element(button).prop('disabled')).toBe(false);
+ });
+ });
- it('changes the title & months format in `month` mode', function() {
- clickTitleButton();
+ it('disables all months in next year', function() {
+ clickTitleButton();
+ clickNextButton();
+ var buttons = getAllOptionsEl();
+ angular.forEach(buttons, function(button, index) {
+ expect(angular.element(button).prop('disabled')).toBe(true);
+ });
+ });
- expect(getTitle()).toBe('10');
- expect(getOptions()).toEqual([
- ['Jan', 'Feb', 'Mar'],
- ['Apr', 'May', 'Jun'],
- ['Jul', 'Aug', 'Sep'],
- ['Oct', 'Nov', 'Dec']
- ]);
+ it('enables everything after if it is cleared', function() {
+ $rootScope.options.maxDate = null;
+ $rootScope.$digest();
+ var buttons = getAllOptionsEl();
+ angular.forEach(buttons, function(button, index) {
+ expect(angular.element(button).prop('disabled')).toBe(false);
+ });
+ });
});
- it('changes the title, year format & range in `year` mode', function() {
- clickTitleButton();
- clickTitleButton();
+ describe('formatting', function() {
+ beforeEach(function() {
+ $rootScope.options = {
+ formatDay: 'd',
+ formatDayHeader: 'EEEE',
+ formatDayTitle: 'MMMM, yy',
+ formatMonth: 'MMM',
+ formatMonthTitle: 'yy',
+ formatYear: 'yy',
+ yearColumns: 4,
+ yearRows: 3
+ };
+ element = $compile('')($rootScope);
+ $rootScope.$digest();
+ });
- expect(getTitle()).toBe('05 - 16');
- expect(getOptions()).toEqual([
- ['05', '06', '07', '08'],
- ['09', '10', '11', '12'],
- ['13', '14', '15', '16']
- ]);
- });
+ it('changes the title format in `day` mode', function() {
+ expect(getTitle()).toBe('September, 10');
+ });
- it('shows day labels', function() {
- expect(getLabels(true)).toEqual(['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']);
- });
+ it('changes the title & months format in `month` mode', function() {
+ clickTitleButton();
- it('changes the day format', function() {
- expect(getOptions(true)).toEqual([
- ['29', '30', '31', '1', '2', '3', '4'],
- ['5', '6', '7', '8', '9', '10', '11'],
- ['12', '13', '14', '15', '16', '17', '18'],
- ['19', '20', '21', '22', '23', '24', '25'],
- ['26', '27', '28', '29', '30', '1', '2'],
- ['3', '4', '5', '6', '7', '8', '9']
- ]);
- });
- });
+ expect(getTitle()).toBe('10');
+ expect(getOptions()).toEqual([
+ ['Jan', 'Feb', 'Mar'],
+ ['Apr', 'May', 'Jun'],
+ ['Jul', 'Aug', 'Sep'],
+ ['Oct', 'Nov', 'Dec']
+ ]);
+ });
- describe('gc', function() {
- var datepickerScope;
- beforeEach(function() {
- $rootScope.minDate = new Date();
- $rootScope.maxDate = new Date();
- $rootScope.maxDate.setDate($rootScope.maxDate.getDate() + 1);
- $rootScope.minMode = 'day';
- $rootScope.maxMode = 'year';
- $rootScope.initDate = new Date();
- element = $compile('')($rootScope);
- $rootScope.$digest();
- datepickerScope = element.isolateScope();
- });
+ it('changes the title, year format & range in `year` mode', function() {
+ clickTitleButton();
+ clickTitleButton();
- it('should appropriately clean up $watch expressions', function() {
- expect($rootScope.$$watchers.length).toBe(6);
- ['minDate', 'maxDate', 'minMode', 'maxMode', 'initDate'].forEach(function(prop) {
- var $$watcher;
- $rootScope.$$watchers.forEach(function($$watch) {
- if ($$watch.exp === prop) {
- $$watcher = $$watch;
- }
- });
- expect(angular.isObject($$watcher)).toBe(true);
+ expect(getTitle()).toBe('05 - 16');
+ expect(getOptions()).toEqual([
+ ['05', '06', '07', '08'],
+ ['09', '10', '11', '12'],
+ ['13', '14', '15', '16']
+ ]);
});
- datepickerScope.$destroy();
+ it('shows day labels', function() {
+ expect(getLabels(true)).toEqual(['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']);
+ });
- expect($rootScope.$$watchers.length).toBe(1);
+ it('changes the day format', function() {
+ expect(getOptions(true)).toEqual([
+ ['29', '30', '31', '1', '2', '3', '4'],
+ ['5', '6', '7', '8', '9', '10', '11'],
+ ['12', '13', '14', '15', '16', '17', '18'],
+ ['19', '20', '21', '22', '23', '24', '25'],
+ ['26', '27', '28', '29', '30', '1', '2'],
+ ['3', '4', '5', '6', '7', '8', '9']
+ ]);
+ });
});
});
@@ -3133,8 +1366,6 @@ describe('datepicker', function() {
angular.extend(originalConfig, uibDatepickerConfig);
uibDatepickerConfig.ngModelOptions = { timezone: '+600' };
$rootScope.date = new Date('2005-11-07T10:00:00.000Z');
- element = $compile('')($rootScope);
- $rootScope.$digest();
}));
afterEach(inject(function(uibDatepickerConfig) {
@@ -3142,27 +1373,38 @@ describe('datepicker', function() {
angular.extend(uibDatepickerConfig, originalConfig);
}));
- it('sets date to appropriate date', function() {
- expectSelectedElement(8);
- });
+ describe('basics', function() {
+ beforeEach(function() {
+ element = $compile('')($rootScope);
+ $rootScope.$digest();
+ });
- it('updates the input when a day is clicked', function() {
- clickOption(9);
- expect($rootScope.date).toEqual(new Date('2005-11-08T10:00:00.000Z'));
+ it('sets date to appropriate date', function() {
+ expectSelectedElement(8);
+ });
+
+ it('updates the input when a day is clicked', function() {
+ clickOption(9);
+ expect($rootScope.date).toEqual(new Date('2005-11-08T10:00:00.000Z'));
+ });
});
it('init date', function() {
- $rootScope.initDate = new Date('2006-01-01T00:00:00.000Z');
+ $rootScope.options = {
+ initDate: new Date('2006-01-01T00:00:00.000Z')
+ };
$rootScope.date = null;
- element = $compile('')($rootScope);
+ element = $compile('')($rootScope);
$rootScope.$digest();
expect(getTitle()).toEqual('January 2006');
});
it('min date', function() {
- $rootScope.minDate = new Date('2010-10-01T00:00:00.000Z');
- element = $compile('')($rootScope);
+ $rootScope.options = {
+ minDate: new Date('2010-10-01T00:00:00.000Z')
+ };
+ element = $compile('')($rootScope);
$rootScope.$digest();
expect(getSelectedElement().prop('disabled')).toBe(true);
@@ -3730,15 +1972,17 @@ describe('datepicker', function() {
});
});
- describe('attribute `init-date`', function() {
+ describe('option `init-date`', function() {
beforeEach(function() {
$rootScope.date = null;
- $rootScope.initDate = new Date('November 9, 1980');
+ $rootScope.options = {
+ initDate: new Date('November 9, 1980')
+ };
});
describe('when initially set', function() {
beforeEach(function() {
- var wrapElement = $compile('')($rootScope);
+ var wrapElement = $compile('')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
});
@@ -3754,11 +1998,11 @@ describe('datepicker', function() {
describe('when modified before date selected.', function() {
beforeEach(function() {
- var wrapElement = $compile('')($rootScope);
+ var wrapElement = $compile('')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
- $rootScope.initDate = new Date('December 20, 1981');
+ $rootScope.options.initDate = new Date('December 20, 1981');
$rootScope.$digest();
});
@@ -3773,11 +2017,11 @@ describe('datepicker', function() {
describe('when modified after date selected.', function() {
beforeEach(function() {
- var wrapElement = $compile('')($rootScope);
+ var wrapElement = $compile('')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
$rootScope.date = new Date('April 1, 1982');
- $rootScope.initDate = new Date('December 20, 1981');
+ $rootScope.options.initDate = new Date('December 20, 1981');
$rootScope.$digest();
});
@@ -4066,8 +2310,12 @@ describe('datepicker', function() {
});
it('should disable today button if before min date', function() {
- $rootScope.minDate = new Date().setDate(new Date().getDate() + 1);
- var wrapElement = $compile('
')($rootScope);
+ var date = new Date();
+ date.setDate(new Date().getDate() + 1);
+ $rootScope.options = {
+ minDate: date
+ };
+ var wrapElement = $compile('
')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
assignButtonBar();
@@ -4076,9 +2324,13 @@ describe('datepicker', function() {
});
it('should disable today button if before min date, yyyy-MM-dd case', inject(function(dateFilter) {
- var minDate = new Date(new Date().setDate(new Date().getDate() + 1));
- var literalMinDate = dateFilter(minDate, 'yyyy-MM-dd');
- var wrapElement = $compile('
')($rootScope);
+ var date = new Date();
+ date.setDate(new Date().getDate() + 1);
+ var literalMinDate = dateFilter(date, 'yyyy-MM-dd');
+ $rootScope.options = {
+ minDate: literalMinDate
+ };
+ var wrapElement = $compile('
')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
assignButtonBar();
@@ -4087,8 +2339,10 @@ describe('datepicker', function() {
}));
it('should not disable any button if min date is null', function() {
- $rootScope.minDate = null;
- var wrapElement = $compile('
')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
assignButtonBar();
@@ -4099,8 +2353,12 @@ describe('datepicker', function() {
});
it('should disable today button if after max date', function() {
- $rootScope.maxDate = new Date().setDate(new Date().getDate() - 2);
- var wrapElement = $compile('
')($rootScope);
+ var date = new Date();
+ date.setDate(new Date().getDate() - 2);
+ $rootScope.options = {
+ maxDate: date
+ };
+ var wrapElement = $compile('
')($rootScope);
$rootScope.$digest();
assignElements(wrapElement);
assignButtonBar();
@@ -4109,8 +2367,10 @@ describe('datepicker', function() {
});
it('should not disable any button if max date is null', function() {
- $rootScope.maxDate = null;
- var wrapElement = $compile('