@@ -836,6 +836,23 @@ describe('input', function() {
836836
837837 expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
838838 } ) ;
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+ } ) ;
839856 } ) ;
840857 } ) ;
841858
@@ -1069,6 +1086,25 @@ describe('input', function() {
10691086
10701087 expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
10711088 } ) ;
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+ } ) ;
10721108 } ) ;
10731109 } ) ;
10741110
@@ -1338,6 +1374,23 @@ describe('input', function() {
13381374
13391375 expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
13401376 } ) ;
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+ } ) ;
13411394 } ) ;
13421395
13431396
@@ -1656,6 +1709,23 @@ describe('input', function() {
16561709
16571710 expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
16581711 } ) ;
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+ } ) ;
16591729 } ) ;
16601730
16611731
@@ -2001,6 +2071,24 @@ describe('input', function() {
20012071
20022072 expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
20032073 } ) ;
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+ } ) ;
20042092 } ) ;
20052093
20062094
0 commit comments