@@ -866,6 +866,23 @@ describe('input', function() {
866866
867867 expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
868868 } ) ;
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+ } ) ;
869886 } ) ;
870887 } ) ;
871888
@@ -1099,6 +1116,25 @@ describe('input', function() {
10991116
11001117 expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
11011118 } ) ;
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+ } ) ;
11021138 } ) ;
11031139 } ) ;
11041140
@@ -1368,6 +1404,23 @@ describe('input', function() {
13681404
13691405 expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
13701406 } ) ;
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+ } ) ;
13711424 } ) ;
13721425
13731426
@@ -1686,6 +1739,23 @@ describe('input', function() {
16861739
16871740 expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
16881741 } ) ;
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+ } ) ;
16891759 } ) ;
16901760
16911761
@@ -2031,6 +2101,24 @@ describe('input', function() {
20312101
20322102 expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
20332103 } ) ;
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+ } ) ;
20342122 } ) ;
20352123
20362124
0 commit comments