@@ -840,6 +840,23 @@ describe('input', function() {
840
840
841
841
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
842
842
} ) ;
843
+
844
+ it ( 'should validate when timezone is provided.' , function ( ) {
845
+ inputElm = helper . compileInput ( '<input type="month" ng-model="value" name="alias" ' +
846
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
847
+ $rootScope . maxVal = '2013-01' ;
848
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 1 , 0 , 0 , 0 ) ) ;
849
+ $rootScope . $digest ( ) ;
850
+
851
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
852
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
853
+
854
+ $rootScope . value = '' ;
855
+ helper . changeInputValueTo ( '2013-01' ) ;
856
+ expect ( inputElm ) . toBeValid ( ) ;
857
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
858
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
859
+ } ) ;
843
860
} ) ;
844
861
} ) ;
845
862
@@ -1073,6 +1090,25 @@ describe('input', function() {
1073
1090
1074
1091
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1075
1092
} ) ;
1093
+
1094
+ it ( 'should validate when timezone is provided.' , function ( ) {
1095
+ inputElm = helper . compileInput ( '<input type="week" ng-model="value" name="alias" ' +
1096
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'-2400\', allowInvalid: true}"/>' ) ;
1097
+ // The calendar week comparison date is January 17. Setting the timezone to -2400
1098
+ // makes the January 18 date value valid.
1099
+ $rootScope . maxVal = '2013-W03' ;
1100
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 18 ) ) ;
1101
+ $rootScope . $digest ( ) ;
1102
+
1103
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1104
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1105
+
1106
+ $rootScope . value = '' ;
1107
+ helper . changeInputValueTo ( '2013-W03' ) ;
1108
+ expect ( inputElm ) . toBeValid ( ) ;
1109
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1110
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1111
+ } ) ;
1076
1112
} ) ;
1077
1113
} ) ;
1078
1114
@@ -1342,6 +1378,23 @@ describe('input', function() {
1342
1378
1343
1379
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1344
1380
} ) ;
1381
+
1382
+ it ( 'should validate when timezone is provided.' , function ( ) {
1383
+ inputElm = helper . compileInput ( '<input type="datetime-local" ng-model="value" name="alias" ' +
1384
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
1385
+ $rootScope . maxVal = '2013-01-01T00:00:00' ;
1386
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 1 , 0 , 0 , 0 ) ) ;
1387
+ $rootScope . $digest ( ) ;
1388
+
1389
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1390
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1391
+
1392
+ $rootScope . value = '' ;
1393
+ helper . changeInputValueTo ( '2013-01-01T00:00:00' ) ;
1394
+ expect ( inputElm ) . toBeValid ( ) ;
1395
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1396
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1397
+ } ) ;
1345
1398
} ) ;
1346
1399
1347
1400
@@ -1660,6 +1713,23 @@ describe('input', function() {
1660
1713
1661
1714
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1662
1715
} ) ;
1716
+
1717
+ it ( 'should validate when timezone is provided.' , function ( ) {
1718
+ inputElm = helper . compileInput ( '<input type="time" ng-model="value" name="alias" ' +
1719
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
1720
+ $rootScope . maxVal = '22:30:00' ;
1721
+ $rootScope . value = new Date ( Date . UTC ( 1970 , 0 , 1 , 22 , 30 , 0 ) ) ;
1722
+ $rootScope . $digest ( ) ;
1723
+
1724
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1725
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1726
+
1727
+ $rootScope . value = '' ;
1728
+ helper . changeInputValueTo ( '22:30:00' ) ;
1729
+ expect ( inputElm ) . toBeValid ( ) ;
1730
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1731
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1732
+ } ) ;
1663
1733
} ) ;
1664
1734
1665
1735
@@ -2005,6 +2075,24 @@ describe('input', function() {
2005
2075
2006
2076
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2007
2077
} ) ;
2078
+
2079
+ it ( 'should validate when timezone is provided.' , function ( ) {
2080
+ var inputElm = helper . compileInput ( '<input type="date" ng-model="value" name="alias" ' +
2081
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
2082
+
2083
+ $rootScope . maxVal = '2013-12-01' ;
2084
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 11 , 1 , 0 , 0 , 0 ) ) ;
2085
+ $rootScope . $digest ( ) ;
2086
+
2087
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2088
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
2089
+
2090
+ $rootScope . value = '' ;
2091
+ helper . changeInputValueTo ( '2013-12-01' ) ;
2092
+ expect ( inputElm ) . toBeValid ( ) ;
2093
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2094
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
2095
+ } ) ;
2008
2096
} ) ;
2009
2097
2010
2098
0 commit comments