@@ -688,6 +688,14 @@ describe('input', function() {
688
688
expect ( inputElm ) . toBeInvalid ( ) ;
689
689
expect ( $rootScope . form . alias . $error . min ) . toBeTruthy ( ) ;
690
690
} ) ;
691
+
692
+ it ( 'should validate if min is empty' , function ( ) {
693
+ $rootScope . minVal = undefined ;
694
+ $rootScope . value = new Date ( - 9999 , 0 , 1 , 0 , 0 , 0 ) ;
695
+ $rootScope . $digest ( ) ;
696
+
697
+ expect ( $rootScope . form . alias . $error . min ) . toBeFalsy ( ) ;
698
+ } ) ;
691
699
} ) ;
692
700
693
701
describe ( 'max' , function ( ) {
@@ -722,6 +730,14 @@ describe('input', function() {
722
730
expect ( inputElm ) . toBeInvalid ( ) ;
723
731
expect ( $rootScope . form . alias . $error . max ) . toBeTruthy ( ) ;
724
732
} ) ;
733
+
734
+ it ( 'should validate if max is empty' , function ( ) {
735
+ $rootScope . maxVal = undefined ;
736
+ $rootScope . value = new Date ( 9999 , 11 , 31 , 23 , 59 , 59 ) ;
737
+ $rootScope . $digest ( ) ;
738
+
739
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
740
+ } ) ;
725
741
} ) ;
726
742
} ) ;
727
743
@@ -886,6 +902,14 @@ describe('input', function() {
886
902
expect ( inputElm ) . toBeInvalid ( ) ;
887
903
expect ( $rootScope . form . alias . $error . min ) . toBeTruthy ( ) ;
888
904
} ) ;
905
+
906
+ it ( 'should validate if min is empty' , function ( ) {
907
+ $rootScope . minVal = undefined ;
908
+ $rootScope . value = new Date ( - 9999 , 0 , 1 , 0 , 0 , 0 ) ;
909
+ $rootScope . $digest ( ) ;
910
+
911
+ expect ( $rootScope . form . alias . $error . min ) . toBeFalsy ( ) ;
912
+ } ) ;
889
913
} ) ;
890
914
891
915
describe ( 'max' , function ( ) {
@@ -921,6 +945,14 @@ describe('input', function() {
921
945
expect ( inputElm ) . toBeInvalid ( ) ;
922
946
expect ( $rootScope . form . alias . $error . max ) . toBeTruthy ( ) ;
923
947
} ) ;
948
+
949
+ it ( 'should validate if max is empty' , function ( ) {
950
+ $rootScope . maxVal = undefined ;
951
+ $rootScope . value = new Date ( 9999 , 11 , 31 , 23 , 59 , 59 ) ;
952
+ $rootScope . $digest ( ) ;
953
+
954
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
955
+ } ) ;
924
956
} ) ;
925
957
} ) ;
926
958
@@ -1119,6 +1151,14 @@ describe('input', function() {
1119
1151
expect ( inputElm ) . toBeInvalid ( ) ;
1120
1152
expect ( $rootScope . form . alias . $error . min ) . toBeTruthy ( ) ;
1121
1153
} ) ;
1154
+
1155
+ it ( 'should validate if min is empty' , function ( ) {
1156
+ $rootScope . minVal = undefined ;
1157
+ $rootScope . value = new Date ( - 9999 , 0 , 1 , 0 , 0 , 0 ) ;
1158
+ $rootScope . $digest ( ) ;
1159
+
1160
+ expect ( $rootScope . form . alias . $error . min ) . toBeFalsy ( ) ;
1161
+ } ) ;
1122
1162
} ) ;
1123
1163
1124
1164
describe ( 'max' , function ( ) {
@@ -1153,6 +1193,14 @@ describe('input', function() {
1153
1193
expect ( inputElm ) . toBeInvalid ( ) ;
1154
1194
expect ( $rootScope . form . alias . $error . max ) . toBeTruthy ( ) ;
1155
1195
} ) ;
1196
+
1197
+ it ( 'should validate if max is empty' , function ( ) {
1198
+ $rootScope . maxVal = undefined ;
1199
+ $rootScope . value = new Date ( 9999 , 11 , 31 , 23 , 59 , 59 ) ;
1200
+ $rootScope . $digest ( ) ;
1201
+
1202
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1203
+ } ) ;
1156
1204
} ) ;
1157
1205
1158
1206
@@ -1428,12 +1476,21 @@ describe('input', function() {
1428
1476
expect ( inputElm ) . toBeInvalid ( ) ;
1429
1477
expect ( $rootScope . form . alias . $error . min ) . toBeTruthy ( ) ;
1430
1478
} ) ;
1479
+
1480
+ it ( 'should validate if min is empty' , function ( ) {
1481
+ $rootScope . minVal = undefined ;
1482
+ $rootScope . value = new Date ( - 9999 , 0 , 1 , 0 , 0 , 0 ) ;
1483
+ $rootScope . $digest ( ) ;
1484
+
1485
+ expect ( $rootScope . form . alias . $error . min ) . toBeFalsy ( ) ;
1486
+ } ) ;
1431
1487
} ) ;
1432
1488
1433
1489
describe ( 'max' , function ( ) {
1434
1490
var inputElm ;
1435
1491
beforeEach ( function ( ) {
1436
- inputElm = helper . compileInput ( '<input type="time" ng-model="value" name="alias" max="22:30:00" />' ) ;
1492
+ $rootScope . maxVal = '22:30:00' ;
1493
+ inputElm = helper . compileInput ( '<input type="time" ng-model="value" name="alias" max="{{ maxVal }}" />' ) ;
1437
1494
} ) ;
1438
1495
1439
1496
it ( 'should invalidate' , function ( ) {
@@ -1449,11 +1506,19 @@ describe('input', function() {
1449
1506
expect ( + $rootScope . value ) . toBe ( + new Date ( 1970 , 0 , 1 , 5 , 30 , 0 ) ) ;
1450
1507
expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1451
1508
} ) ;
1509
+
1510
+ it ( 'should validate if max is empty' , function ( ) {
1511
+ $rootScope . maxVal = undefined ;
1512
+ $rootScope . value = new Date ( 9999 , 11 , 31 , 23 , 59 , 59 ) ;
1513
+ $rootScope . $digest ( ) ;
1514
+
1515
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1516
+ } ) ;
1452
1517
} ) ;
1453
1518
1454
1519
1455
1520
it ( 'should validate even if max value changes on-the-fly' , function ( ) {
1456
- $rootScope . max = '4 :02:00' ;
1521
+ $rootScope . max = '04 :02:00' ;
1457
1522
var inputElm = helper . compileInput ( '<input type="time" ng-model="value" name="alias" max="{{max}}" />' ) ;
1458
1523
1459
1524
helper . changeInputValueTo ( '05:34:00' ) ;
@@ -1481,7 +1546,7 @@ describe('input', function() {
1481
1546
1482
1547
1483
1548
it ( 'should validate even if ng-max value changes on-the-fly' , function ( ) {
1484
- $rootScope . max = '4 :02:00' ;
1549
+ $rootScope . max = '04 :02:00' ;
1485
1550
var inputElm = helper . compileInput ( '<input type="time" ng-model="value" name="alias" ng-max="max" />' ) ;
1486
1551
1487
1552
helper . changeInputValueTo ( '05:34:00' ) ;
@@ -1706,6 +1771,16 @@ describe('input', function() {
1706
1771
1707
1772
expect ( $rootScope . form . myControl . $error . min ) . toBeTruthy ( ) ;
1708
1773
} ) ;
1774
+
1775
+ it ( 'should validate if min is empty' , function ( ) {
1776
+ var inputElm = helper . compileInput (
1777
+ '<input type="date" name="alias" ng-model="value" min />' ) ;
1778
+
1779
+ $rootScope . value = new Date ( - 9999 , 0 , 1 , 0 , 0 , 0 ) ;
1780
+ $rootScope . $digest ( ) ;
1781
+
1782
+ expect ( $rootScope . form . alias . $error . min ) . toBeFalsy ( ) ;
1783
+ } ) ;
1709
1784
} ) ;
1710
1785
1711
1786
describe ( 'max' , function ( ) {
@@ -1735,6 +1810,16 @@ describe('input', function() {
1735
1810
1736
1811
expect ( $rootScope . form . myControl . $error . max ) . toBeTruthy ( ) ;
1737
1812
} ) ;
1813
+
1814
+ it ( 'should validate if max is empty' , function ( ) {
1815
+ var inputElm = helper . compileInput (
1816
+ '<input type="date" name="alias" ng-model="value" max />' ) ;
1817
+
1818
+ $rootScope . value = new Date ( 9999 , 11 , 31 , 23 , 59 , 59 ) ;
1819
+ $rootScope . $digest ( ) ;
1820
+
1821
+ expect ( $rootScope . form . alias . $error . max ) . toBeFalsy ( ) ;
1822
+ } ) ;
1738
1823
} ) ;
1739
1824
1740
1825
0 commit comments