@@ -2526,6 +2526,42 @@ describe('input', function() {
2526
2526
2527
2527
expect ( inputElm ) . toBeValid ( ) ;
2528
2528
} ) ;
2529
+
2530
+ it ( 'should validate even if ng-max value changes on-the-fly' , function ( ) {
2531
+ scope . max = '2013-01-01T01:02:00' ;
2532
+ compileInput ( '<input type="datetime-local" ng-model="value" name="alias" ng-max="max" />' ) ;
2533
+
2534
+ changeInputValueTo ( '2014-01-01T12:34:00' ) ;
2535
+ expect ( inputElm ) . toBeInvalid ( ) ;
2536
+
2537
+ scope . max = '2001-01-01T01:02:00' ;
2538
+ scope . $digest ( ) ;
2539
+
2540
+ expect ( inputElm ) . toBeInvalid ( ) ;
2541
+
2542
+ scope . max = '2024-01-01T01:02:00' ;
2543
+ scope . $digest ( ) ;
2544
+
2545
+ expect ( inputElm ) . toBeValid ( ) ;
2546
+ } ) ;
2547
+
2548
+ it ( 'should validate even if ng-min value changes on-the-fly' , function ( ) {
2549
+ scope . min = '2013-01-01T01:02:00' ;
2550
+ compileInput ( '<input type="datetime-local" ng-model="value" name="alias" ng-min="min" />' ) ;
2551
+
2552
+ changeInputValueTo ( '2010-01-01T12:34:00' ) ;
2553
+ expect ( inputElm ) . toBeInvalid ( ) ;
2554
+
2555
+ scope . min = '2014-01-01T01:02:00' ;
2556
+ scope . $digest ( ) ;
2557
+
2558
+ expect ( inputElm ) . toBeInvalid ( ) ;
2559
+
2560
+ scope . min = '2009-01-01T01:02:00' ;
2561
+ scope . $digest ( ) ;
2562
+
2563
+ expect ( inputElm ) . toBeValid ( ) ;
2564
+ } ) ;
2529
2565
} ) ;
2530
2566
2531
2567
describe ( 'time' , function ( ) {
@@ -2726,6 +2762,32 @@ describe('input', function() {
2726
2762
2727
2763
expect ( inputElm ) . toBeValid ( ) ;
2728
2764
} ) ;
2765
+
2766
+ it ( 'should validate even if ng-max value changes on-the-fly' , function ( ) {
2767
+ scope . max = '4:02:00' ;
2768
+ compileInput ( '<input type="time" ng-model="value" name="alias" ng-max="max" />' ) ;
2769
+
2770
+ changeInputValueTo ( '05:34:00' ) ;
2771
+ expect ( inputElm ) . toBeInvalid ( ) ;
2772
+
2773
+ scope . max = '06:34:00' ;
2774
+ scope . $digest ( ) ;
2775
+
2776
+ expect ( inputElm ) . toBeValid ( ) ;
2777
+ } ) ;
2778
+
2779
+ it ( 'should validate even if ng-min value changes on-the-fly' , function ( ) {
2780
+ scope . min = '08:45:00' ;
2781
+ compileInput ( '<input type="time" ng-model="value" name="alias" ng-min="min" />' ) ;
2782
+
2783
+ changeInputValueTo ( '06:15:00' ) ;
2784
+ expect ( inputElm ) . toBeInvalid ( ) ;
2785
+
2786
+ scope . min = '05:50:00' ;
2787
+ scope . $digest ( ) ;
2788
+
2789
+ expect ( inputElm ) . toBeValid ( ) ;
2790
+ } ) ;
2729
2791
} ) ;
2730
2792
2731
2793
describe ( 'date' , function ( ) {
@@ -2936,6 +2998,42 @@ describe('input', function() {
2936
2998
2937
2999
expect ( inputElm ) . toBeValid ( ) ;
2938
3000
} ) ;
3001
+
3002
+ it ( 'should validate even if ng-max value changes on-the-fly' , function ( ) {
3003
+ scope . max = '2013-01-01' ;
3004
+ compileInput ( '<input type="date" ng-model="value" name="alias" ng-max="max" />' ) ;
3005
+
3006
+ changeInputValueTo ( '2014-01-01' ) ;
3007
+ expect ( inputElm ) . toBeInvalid ( ) ;
3008
+
3009
+ scope . max = '2001-01-01' ;
3010
+ scope . $digest ( ) ;
3011
+
3012
+ expect ( inputElm ) . toBeInvalid ( ) ;
3013
+
3014
+ scope . max = '2021-01-01' ;
3015
+ scope . $digest ( ) ;
3016
+
3017
+ expect ( inputElm ) . toBeValid ( ) ;
3018
+ } ) ;
3019
+
3020
+ it ( 'should validate even if ng-min value changes on-the-fly' , function ( ) {
3021
+ scope . min = '2013-01-01' ;
3022
+ compileInput ( '<input type="date" ng-model="value" name="alias" ng-min="min" />' ) ;
3023
+
3024
+ changeInputValueTo ( '2010-01-01' ) ;
3025
+ expect ( inputElm ) . toBeInvalid ( ) ;
3026
+
3027
+ scope . min = '2014-01-01' ;
3028
+ scope . $digest ( ) ;
3029
+
3030
+ expect ( inputElm ) . toBeInvalid ( ) ;
3031
+
3032
+ scope . min = '2009-01-01' ;
3033
+ scope . $digest ( ) ;
3034
+
3035
+ expect ( inputElm ) . toBeValid ( ) ;
3036
+ } ) ;
2939
3037
} ) ;
2940
3038
2941
3039
describe ( 'number' , function ( ) {
0 commit comments