@@ -836,6 +836,23 @@ describe('input', function() {
836
836
837
837
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
838
838
} ) ;
839
+
840
+ it ( 'should validate when timezone is provided.' , function ( ) {
841
+ inputElm = helper . compileInput ( '<input type="month" ng-model="value" name="alias" ' +
842
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
843
+ $rootScope . maxVal = '2013-01' ;
844
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 1 , 0 , 0 , 0 ) ) ;
845
+ $rootScope . $digest ( ) ;
846
+
847
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
848
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
849
+
850
+ $rootScope . value = '' ;
851
+ helper . changeInputValueTo ( '2013-01' ) ;
852
+ expect ( inputElm ) . toBeValid ( ) ;
853
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
854
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
855
+ } ) ;
839
856
} ) ;
840
857
} ) ;
841
858
@@ -1069,6 +1086,25 @@ describe('input', function() {
1069
1086
1070
1087
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1071
1088
} ) ;
1089
+
1090
+ it ( 'should validate when timezone is provided.' , function ( ) {
1091
+ inputElm = helper . compileInput ( '<input type="week" ng-model="value" name="alias" ' +
1092
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'-2400\', allowInvalid: true}"/>' ) ;
1093
+ // The calendar week comparison date is January 17. Setting the timezone to -2400
1094
+ // makes the January 18 date value valid.
1095
+ $rootScope . maxVal = '2013-W03' ;
1096
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 18 ) ) ;
1097
+ $rootScope . $digest ( ) ;
1098
+
1099
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1100
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1101
+
1102
+ $rootScope . value = '' ;
1103
+ helper . changeInputValueTo ( '2013-W03' ) ;
1104
+ expect ( inputElm ) . toBeValid ( ) ;
1105
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1106
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1107
+ } ) ;
1072
1108
} ) ;
1073
1109
} ) ;
1074
1110
@@ -1338,6 +1374,23 @@ describe('input', function() {
1338
1374
1339
1375
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1340
1376
} ) ;
1377
+
1378
+ it ( 'should validate when timezone is provided.' , function ( ) {
1379
+ inputElm = helper . compileInput ( '<input type="datetime-local" ng-model="value" name="alias" ' +
1380
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
1381
+ $rootScope . maxVal = '2013-01-01T00:00:00' ;
1382
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 1 , 0 , 0 , 0 ) ) ;
1383
+ $rootScope . $digest ( ) ;
1384
+
1385
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1386
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1387
+
1388
+ $rootScope . value = '' ;
1389
+ helper . changeInputValueTo ( '2013-01-01T00:00:00' ) ;
1390
+ expect ( inputElm ) . toBeValid ( ) ;
1391
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1392
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1393
+ } ) ;
1341
1394
} ) ;
1342
1395
1343
1396
@@ -1656,6 +1709,23 @@ describe('input', function() {
1656
1709
1657
1710
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1658
1711
} ) ;
1712
+
1713
+ it ( 'should validate when timezone is provided.' , function ( ) {
1714
+ inputElm = helper . compileInput ( '<input type="time" ng-model="value" name="alias" ' +
1715
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
1716
+ $rootScope . maxVal = '22:30:00' ;
1717
+ $rootScope . value = new Date ( Date . UTC ( 1970 , 0 , 1 , 22 , 30 , 0 ) ) ;
1718
+ $rootScope . $digest ( ) ;
1719
+
1720
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1721
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1722
+
1723
+ $rootScope . value = '' ;
1724
+ helper . changeInputValueTo ( '22:30:00' ) ;
1725
+ expect ( inputElm ) . toBeValid ( ) ;
1726
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1727
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1728
+ } ) ;
1659
1729
} ) ;
1660
1730
1661
1731
@@ -2001,6 +2071,24 @@ describe('input', function() {
2001
2071
2002
2072
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2003
2073
} ) ;
2074
+
2075
+ it ( 'should validate when timezone is provided.' , function ( ) {
2076
+ var inputElm = helper . compileInput ( '<input type="date" ng-model="value" name="alias" ' +
2077
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
2078
+
2079
+ $rootScope . maxVal = '2013-12-01' ;
2080
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 11 , 1 , 0 , 0 , 0 ) ) ;
2081
+ $rootScope . $digest ( ) ;
2082
+
2083
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2084
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
2085
+
2086
+ $rootScope . value = '' ;
2087
+ helper . changeInputValueTo ( '2013-12-01' ) ;
2088
+ expect ( inputElm ) . toBeValid ( ) ;
2089
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2090
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
2091
+ } ) ;
2004
2092
} ) ;
2005
2093
2006
2094
0 commit comments