From 93da30d559481cc603586420341d32a5fc23bd58 Mon Sep 17 00:00:00 2001 From: Rafael Garcia Date: Sat, 15 Feb 2014 18:00:09 -0300 Subject: [PATCH] fix(datepicker): rename `dateFormat` to `datepickerPopup` in datepickerPopupConfig Closes #1810 --- src/datepicker/datepicker.js | 4 ++-- src/datepicker/test/datepicker.spec.js | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/datepicker/datepicker.js b/src/datepicker/datepicker.js index b0a3b932a1..4dae6719e6 100644 --- a/src/datepicker/datepicker.js +++ b/src/datepicker/datepicker.js @@ -296,7 +296,7 @@ angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.position']) }) .constant('datepickerPopupConfig', { - dateFormat: 'yyyy-MM-dd', + datepickerPopup: 'yyyy-MM-dd', currentText: 'Today', clearText: 'Clear', closeText: 'Done', @@ -328,7 +328,7 @@ function ($compile, $parse, $document, $position, dateFilter, datepickerPopupCon }; attrs.$observe('datepickerPopup', function(value) { - dateFormat = value || datepickerPopupConfig.dateFormat; + dateFormat = value || datepickerPopupConfig.datepickerPopup; ngModel.$render(); }); diff --git a/src/datepicker/test/datepicker.spec.js b/src/datepicker/test/datepicker.spec.js index 575dae700c..d8083c3ce3 100644 --- a/src/datepicker/test/datepicker.spec.js +++ b/src/datepicker/test/datepicker.spec.js @@ -795,6 +795,26 @@ describe('datepicker directive', function () { }); + describe('setting datepickerPopupConfig', function() { + var originalConfig = {}; + beforeEach(inject(function(datepickerPopupConfig) { + angular.extend(originalConfig, datepickerPopupConfig); + datepickerPopupConfig.datepickerPopup = 'MM-dd-yyyy'; + + element = $compile('')($rootScope); + $rootScope.$digest(); + })); + afterEach(inject(function(datepickerPopupConfig) { + // return it to the original state + angular.extend(datepickerPopupConfig, originalConfig); + })); + + it('changes date format', function() { + expect(element.val()).toEqual('09-30-2010'); + }); + + }); + describe('as popup', function () { var inputEl, dropdownEl, changeInputValueTo, $document;