@@ -1849,6 +1849,110 @@ describe('datepicker', function() {
1849
1849
expect ( getTitle ( ) ) . toBe ( 'November 1980' ) ;
1850
1850
} ) ;
1851
1851
} ) ;
1852
+
1853
+ describe ( 'min-date' , function ( ) {
1854
+ it ( 'should be able to specify a min-date through options' , function ( ) {
1855
+ $rootScope . opts = {
1856
+ minDate : new Date ( 'September 12, 2010' ) ,
1857
+ shortcutPropagation : 'dog'
1858
+ } ;
1859
+
1860
+ var wrapElement = $compile ( '<div><input ng-model="date" uib-datepicker-popup datepicker-options="opts" is-open="true"></div>' ) ( $rootScope ) ;
1861
+ $rootScope . $digest ( ) ;
1862
+ assignElements ( wrapElement ) ;
1863
+
1864
+ var buttons = getAllOptionsEl ( ) ;
1865
+ angular . forEach ( buttons , function ( button , index ) {
1866
+ expect ( angular . element ( button ) . prop ( 'disabled' ) ) . toBe ( index < 14 ) ;
1867
+ } ) ;
1868
+
1869
+ $rootScope . opts . minDate = new Date ( 'September 13, 2010' ) ;
1870
+ $rootScope . $digest ( ) ;
1871
+ buttons = getAllOptionsEl ( ) ;
1872
+ angular . forEach ( buttons , function ( button , index ) {
1873
+ expect ( angular . element ( button ) . prop ( 'disabled' ) ) . toBe ( index < 15 ) ;
1874
+ } ) ;
1875
+ } ) ;
1876
+ } ) ;
1877
+
1878
+ describe ( 'max-date' , function ( ) {
1879
+ it ( 'should be able to specify a max-date through options' , function ( ) {
1880
+ $rootScope . opts = {
1881
+ maxDate : new Date ( 'September 25, 2010' )
1882
+ } ;
1883
+
1884
+ var wrapElement = $compile ( '<div><input ng-model="date" uib-datepicker-popup datepicker-options="opts" is-open="true"></div>' ) ( $rootScope ) ;
1885
+ $rootScope . $digest ( ) ;
1886
+ assignElements ( wrapElement ) ;
1887
+
1888
+ var buttons = getAllOptionsEl ( ) ;
1889
+ angular . forEach ( buttons , function ( button , index ) {
1890
+ expect ( angular . element ( button ) . prop ( 'disabled' ) ) . toBe ( index > 27 ) ;
1891
+ } ) ;
1892
+
1893
+ $rootScope . opts . maxDate = new Date ( 'September 15, 2010' ) ;
1894
+ $rootScope . $digest ( ) ;
1895
+ buttons = getAllOptionsEl ( ) ;
1896
+ angular . forEach ( buttons , function ( button , index ) {
1897
+ expect ( angular . element ( button ) . prop ( 'disabled' ) ) . toBe ( index > 17 ) ;
1898
+ } ) ;
1899
+ } ) ;
1900
+ } ) ;
1901
+
1902
+ describe ( 'min-mode' , function ( ) {
1903
+ it ( 'should be able to specify min-mode through options' , function ( ) {
1904
+ $rootScope . opts = {
1905
+ minMode : 'month'
1906
+ } ;
1907
+
1908
+ var wrapElement = $compile ( '<div><input ng-model="date" uib-datepicker-popup datepicker-options="opts" is-open="true"></div>' ) ( $rootScope ) ;
1909
+ $rootScope . $digest ( ) ;
1910
+ assignElements ( wrapElement ) ;
1911
+
1912
+ expect ( getTitle ( ) ) . toBe ( '2010' ) ;
1913
+ } ) ;
1914
+ } ) ;
1915
+
1916
+ describe ( 'max-mode' , function ( ) {
1917
+ it ( 'should be able to specify max-mode through options' , function ( ) {
1918
+ $rootScope . opts = {
1919
+ maxMode : 'month'
1920
+ } ;
1921
+
1922
+ var wrapElement = $compile ( '<div><input ng-model="date" uib-datepicker-popup datepicker-options="opts" is-open="true"></div>' ) ( $rootScope ) ;
1923
+ $rootScope . $digest ( ) ;
1924
+ assignElements ( wrapElement ) ;
1925
+
1926
+ expect ( getTitle ( ) ) . toBe ( 'September 2010' ) ;
1927
+ clickTitleButton ( ) ;
1928
+ assignElements ( wrapElement ) ;
1929
+ expect ( getTitle ( ) ) . toBe ( '2010' ) ;
1930
+ clickTitleButton ( ) ;
1931
+ assignElements ( wrapElement ) ;
1932
+ expect ( getTitle ( ) ) . toBe ( '2010' ) ;
1933
+ } ) ;
1934
+ } ) ;
1935
+
1936
+ describe ( 'datepicker-mode' , function ( ) {
1937
+ beforeEach ( inject ( function ( ) {
1938
+ $rootScope . date = new Date ( 'August 11, 2013' ) ;
1939
+ $rootScope . opts = {
1940
+ datepickerMode : 'month'
1941
+ } ;
1942
+ var wrapElement = $compile ( '<div><input ng-model="date" uib-datepicker-popup datepicker-options="opts" is-open="true"></div>' ) ( $rootScope ) ;
1943
+ $rootScope . $digest ( ) ;
1944
+ assignElements ( wrapElement ) ;
1945
+ } ) ) ;
1946
+
1947
+ it ( 'shows the correct title' , function ( ) {
1948
+ expect ( getTitle ( ) ) . toBe ( '2013' ) ;
1949
+ } ) ;
1950
+
1951
+ it ( 'updates binding' , function ( ) {
1952
+ clickTitleButton ( ) ;
1953
+ expect ( $rootScope . opts . datepickerMode ) . toBe ( 'year' ) ;
1954
+ } ) ;
1955
+ } ) ;
1852
1956
} ) ;
1853
1957
1854
1958
describe ( 'attribute `init-date`' , function ( ) {
0 commit comments