@@ -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,23 @@ 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: \'UTC\', allowInvalid: true}"/>' ) ;
1097
+ $rootScope . maxVal = '2013-W01' ;
1098
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 1 , 0 , 0 , 0 ) ) ;
1099
+ $rootScope . $digest ( ) ;
1100
+
1101
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1102
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1103
+
1104
+ $rootScope . value = '' ;
1105
+ helper . changeInputValueTo ( '2013-W01' ) ;
1106
+ expect ( inputElm ) . toBeValid ( ) ;
1107
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1108
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1109
+ } ) ;
1076
1110
} ) ;
1077
1111
} ) ;
1078
1112
@@ -1342,6 +1376,23 @@ describe('input', function() {
1342
1376
1343
1377
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1344
1378
} ) ;
1379
+
1380
+ it ( 'should validate when timezone is provided.' , function ( ) {
1381
+ inputElm = helper . compileInput ( '<input type="datetime-local" ng-model="value" name="alias" ' +
1382
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
1383
+ $rootScope . maxVal = '2013-01-01T00:00:00' ;
1384
+ $rootScope . value = new Date ( Date . UTC ( 2013 , 0 , 1 , 0 , 0 , 0 ) ) ;
1385
+ $rootScope . $digest ( ) ;
1386
+
1387
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1388
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1389
+
1390
+ $rootScope . value = '' ;
1391
+ helper . changeInputValueTo ( '2013-01-01T00:00:00' ) ;
1392
+ expect ( inputElm ) . toBeValid ( ) ;
1393
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1394
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1395
+ } ) ;
1345
1396
} ) ;
1346
1397
1347
1398
@@ -1660,6 +1711,23 @@ describe('input', function() {
1660
1711
1661
1712
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1662
1713
} ) ;
1714
+
1715
+ it ( 'should validate when timezone is provided.' , function ( ) {
1716
+ inputElm = helper . compileInput ( '<input type="time" ng-model="value" name="alias" ' +
1717
+ 'max="{{ maxVal }}" ng-model-options="{timezone: \'UTC\', allowInvalid: true}"/>' ) ;
1718
+ $rootScope . maxVal = '22:30:00' ;
1719
+ $rootScope . value = new Date ( Date . UTC ( 1970 , 0 , 1 , 22 , 30 , 0 ) ) ;
1720
+ $rootScope . $digest ( ) ;
1721
+
1722
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1723
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1724
+
1725
+ $rootScope . value = '' ;
1726
+ helper . changeInputValueTo ( '22:30:00' ) ;
1727
+ expect ( inputElm ) . toBeValid ( ) ;
1728
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1729
+ expect ( $rootScope . form . alias . $valid ) . toBeTruthy ( ) ;
1730
+ } ) ;
1663
1731
} ) ;
1664
1732
1665
1733
0 commit comments