@@ -866,6 +866,23 @@ describe('input', function() {
866
866
867
867
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
868
868
} ) ;
869
+
870
+ it ( 'should validate when timezone is provided.' , function ( ) {
871
+ inputElm = helper . compileInput ( '<input type="month" ng-model="value" name="alias" ' +
872
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
873
+ $rootScope . maxVal = '2013-01' ;
874
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 1 , 0 , 0 , 0 ) ) ;
875
+ $rootScope . $digest ( ) ;
876
+
877
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
878
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
879
+
880
+ $rootScope . value = '' ;
881
+ helper . changeInputValueTo ( '2013-01' ) ;
882
+ expect ( inputElm ) . toBeValid ( ) ;
883
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
884
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
885
+ } ) ;
869
886
} ) ;
870
887
} ) ;
871
888
@@ -1099,6 +1116,25 @@ describe('input', function() {
1099
1116
1100
1117
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1101
1118
} ) ;
1119
+
1120
+ it ( 'should validate when timezone is provided.' , function ( ) {
1121
+ inputElm = helper . compileInput ( '<input type="week" ng-model="value" name="alias" ' +
1122
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'-2400\', allowInvalid: true}"/>' ) ;
1123
+ // The calendar week comparison date is January 17. Setting the timezone to -2400
1124
+ // makes the January 18 date value valid.
1125
+ $rootScope . maxVal = '2013-W03' ;
1126
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 18 ) ) ;
1127
+ $rootScope . $digest ( ) ;
1128
+
1129
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1130
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1131
+
1132
+ $rootScope . value = '' ;
1133
+ helper . changeInputValueTo ( '2013-W03' ) ;
1134
+ expect ( inputElm ) . toBeValid ( ) ;
1135
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1136
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1137
+ } ) ;
1102
1138
} ) ;
1103
1139
} ) ;
1104
1140
@@ -1368,6 +1404,23 @@ describe('input', function() {
1368
1404
1369
1405
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1370
1406
} ) ;
1407
+
1408
+ it ( 'should validate when timezone is provided.' , function ( ) {
1409
+ inputElm = helper . compileInput ( '<input type="datetime-local" ng-model="value" name="alias" ' +
1410
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
1411
+ $rootScope . maxVal = '2013-01-01T00:00:00' ;
1412
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 1 , 0 , 0 , 0 ) ) ;
1413
+ $rootScope . $digest ( ) ;
1414
+
1415
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1416
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1417
+
1418
+ $rootScope . value = '' ;
1419
+ helper . changeInputValueTo ( '2013-01-01T00:00:00' ) ;
1420
+ expect ( inputElm ) . toBeValid ( ) ;
1421
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1422
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1423
+ } ) ;
1371
1424
} ) ;
1372
1425
1373
1426
@@ -1686,6 +1739,23 @@ describe('input', function() {
1686
1739
1687
1740
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1688
1741
} ) ;
1742
+
1743
+ it ( 'should validate when timezone is provided.' , function ( ) {
1744
+ inputElm = helper . compileInput ( '<input type="time" ng-model="value" name="alias" ' +
1745
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
1746
+ $rootScope . maxVal = '22:30:00' ;
1747
+ $rootScope . value = new Date ( Date . UTC ( 1970 , 0 , 1 , 22 , 30 , 0 ) ) ;
1748
+ $rootScope . $digest ( ) ;
1749
+
1750
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1751
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1752
+
1753
+ $rootScope . value = '' ;
1754
+ helper . changeInputValueTo ( '22:30:00' ) ;
1755
+ expect ( inputElm ) . toBeValid ( ) ;
1756
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1757
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1758
+ } ) ;
1689
1759
} ) ;
1690
1760
1691
1761
@@ -2031,6 +2101,24 @@ describe('input', function() {
2031
2101
2032
2102
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2033
2103
} ) ;
2104
+
2105
+ it ( 'should validate when timezone is provided.' , function ( ) {
2106
+ var inputElm = helper . compileInput ( '<input type="date" ng-model="value" name="alias" ' +
2107
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
2108
+
2109
+ $rootScope . maxVal = '2013-12-01' ;
2110
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 11 , 1 , 0 , 0 , 0 ) ) ;
2111
+ $rootScope . $digest ( ) ;
2112
+
2113
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2114
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
2115
+
2116
+ $rootScope . value = '' ;
2117
+ helper . changeInputValueTo ( '2013-12-01' ) ;
2118
+ expect ( inputElm ) . toBeValid ( ) ;
2119
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2120
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
2121
+ } ) ;
2034
2122
} ) ;
2035
2123
2036
2124
0 commit comments