@@ -2465,6 +2465,21 @@ describe('input', function() {
2465
2465
expect ( $rootScope . form . alias . $error . min ) . toBeFalsy ( ) ;
2466
2466
} ) ;
2467
2467
2468
+
2469
+ it ( 'should validate against the viewValue' , function ( ) {
2470
+ var inputElm = helper . compileInput ( '<input type="number" num-parse ng-model="value" name="alias" min="10" />' ) ;
2471
+ var ngModelCtrl = inputElm . controller ( 'ngModel' ) ;
2472
+ ngModelCtrl . $parsers . push ( function ( value ) {
2473
+ return value - 5 ;
2474
+ } ) ;
2475
+
2476
+ helper . changeInputValueTo ( '10' ) ;
2477
+ expect ( inputElm ) . toBeValid ( ) ;
2478
+ expect ( $rootScope . value ) . toBe ( 5 ) ;
2479
+ expect ( $rootScope . form . alias . $error . min ) . toBeFalsy ( ) ;
2480
+ } ) ;
2481
+
2482
+
2468
2483
it ( 'should validate even if min value changes on-the-fly' , function ( ) {
2469
2484
$rootScope . min = undefined ;
2470
2485
var inputElm = helper . compileInput ( '<input type="number" ng-model="value" name="alias" min="{{min}}" />' ) ;
@@ -2511,6 +2526,21 @@ describe('input', function() {
2511
2526
expect ( $rootScope . form . alias . $error . min ) . toBeFalsy ( ) ;
2512
2527
} ) ;
2513
2528
2529
+
2530
+ it ( 'should validate against the viewValue' , function ( ) {
2531
+ var inputElm = helper . compileInput ( '<input type="number" num-parse ng-model="value" name="alias" ng-min="10" />' ) ;
2532
+ var ngModelCtrl = inputElm . controller ( 'ngModel' ) ;
2533
+ ngModelCtrl . $parsers . push ( function ( value ) {
2534
+ return value - 5 ;
2535
+ } ) ;
2536
+
2537
+ helper . changeInputValueTo ( '10' ) ;
2538
+ expect ( inputElm ) . toBeValid ( ) ;
2539
+ expect ( $rootScope . value ) . toBe ( 5 ) ;
2540
+ expect ( $rootScope . form . alias . $error . min ) . toBeFalsy ( ) ;
2541
+ } ) ;
2542
+
2543
+
2514
2544
it ( 'should validate even if the ngMin value changes on-the-fly' , function ( ) {
2515
2545
$rootScope . min = undefined ;
2516
2546
var inputElm = helper . compileInput ( '<input type="number" ng-model="value" name="alias" ng-min="min" />' ) ;
@@ -2558,6 +2588,22 @@ describe('input', function() {
2558
2588
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2559
2589
} ) ;
2560
2590
2591
+
2592
+ it ( 'should validate against the viewValue' , function ( ) {
2593
+ var inputElm = helper . compileInput ( '<input type="number"' +
2594
+ 'num-parse ng-model="value" name="alias" max="10" />' ) ;
2595
+ var ngModelCtrl = inputElm . controller ( 'ngModel' ) ;
2596
+ ngModelCtrl . $parsers . push ( function ( value ) {
2597
+ return value + 5 ;
2598
+ } ) ;
2599
+
2600
+ helper . changeInputValueTo ( '9' ) ;
2601
+ expect ( inputElm ) . toBeValid ( ) ;
2602
+ expect ( $rootScope . value ) . toBe ( 14 ) ;
2603
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2604
+ } ) ;
2605
+
2606
+
2561
2607
it ( 'should validate even if max value changes on-the-fly' , function ( ) {
2562
2608
$rootScope . max = undefined ;
2563
2609
var inputElm = helper . compileInput ( '<input type="number" ng-model="value" name="alias" max="{{max}}" />' ) ;
@@ -2604,6 +2650,22 @@ describe('input', function() {
2604
2650
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2605
2651
} ) ;
2606
2652
2653
+
2654
+ it ( 'should validate against the viewValue' , function ( ) {
2655
+ var inputElm = helper . compileInput ( '<input type="number"' +
2656
+ 'num-parse ng-model="value" name="alias" ng-max="10" />' ) ;
2657
+ var ngModelCtrl = inputElm . controller ( 'ngModel' ) ;
2658
+ ngModelCtrl . $parsers . push ( function ( value ) {
2659
+ return value + 5 ;
2660
+ } ) ;
2661
+
2662
+ helper . changeInputValueTo ( '9' ) ;
2663
+ expect ( inputElm ) . toBeValid ( ) ;
2664
+ expect ( $rootScope . value ) . toBe ( 14 ) ;
2665
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
2666
+ } ) ;
2667
+
2668
+
2607
2669
it ( 'should validate even if the ngMax value changes on-the-fly' , function ( ) {
2608
2670
$rootScope . max = undefined ;
2609
2671
var inputElm = helper . compileInput ( '<input type="number" ng-model="value" name="alias" ng-max="max" />' ) ;
0 commit comments