@@ -751,7 +751,6 @@ describe('input', function() {
751
751
752
752
753
753
// INPUT TYPES
754
-
755
754
describe ( 'week' , function ( ) {
756
755
it ( 'should set the view if the model is valid ISO8601 week' , function ( ) {
757
756
compileInput ( '<input type="week" ng-model="secondWeek"/>' ) ;
@@ -798,6 +797,58 @@ describe('input', function() {
798
797
799
798
800
799
800
+ describe ( 'min' , function ( ) {
801
+ beforeEach ( function ( ) {
802
+ compileInput ( '<input type="week" ng-model="value" name="alias" min="2013-W01" />' ) ;
803
+ scope . $digest ( ) ;
804
+ } ) ;
805
+
806
+ it ( 'should invalidate' , function ( ) {
807
+ changeInputValueTo ( '2012-W12' ) ;
808
+ expect ( inputElm ) . toBeInvalid ( ) ;
809
+ expect ( scope . value ) . toBeFalsy ( ) ;
810
+ expect ( scope . form . alias . $error . min ) . toBeTruthy ( ) ;
811
+ } ) ;
812
+
813
+ it ( 'should validate' , function ( ) {
814
+ changeInputValueTo ( '2013-W03' ) ;
815
+ expect ( inputElm ) . toBeValid ( ) ;
816
+ expect ( + scope . value ) . toBe ( + new Date ( 2013 , 0 , 17 ) ) ;
817
+ expect ( scope . form . alias . $error . min ) . toBeFalsy ( ) ;
818
+ } ) ;
819
+ } ) ;
820
+
821
+ describe ( 'max' , function ( ) {
822
+ beforeEach ( function ( ) {
823
+ compileInput ( '<input type="week" ng-model="value" name="alias" max="2013-W01" />' ) ;
824
+ scope . $digest ( ) ;
825
+ } ) ;
826
+
827
+ it ( 'should validate' , function ( ) {
828
+ changeInputValueTo ( '2012-W01' ) ;
829
+ expect ( inputElm ) . toBeValid ( ) ;
830
+ expect ( + scope . value ) . toBe ( + new Date ( 2012 , 0 , 5 ) ) ;
831
+ expect ( scope . form . alias . $error . max ) . toBeFalsy ( ) ;
832
+ } ) ;
833
+
834
+ it ( 'should invalidate' , function ( ) {
835
+ changeInputValueTo ( '2013-W03' ) ;
836
+ expect ( inputElm ) . toBeInvalid ( ) ;
837
+ expect ( scope . value ) . toBeUndefined ( ) ;
838
+ expect ( scope . form . alias . $error . max ) . toBeTruthy ( ) ;
839
+ } ) ;
840
+ } ) ;
841
+ } ) ;
842
+ }
843
+
844
+ changeInputValueTo ( 'stuff' ) ;
845
+ expect ( inputElm . val ( ) ) . toBe ( 'stuff' ) ;
846
+ expect ( scope . value ) . toBeUndefined ( ) ;
847
+ expect ( inputElm ) . toBeInvalid ( ) ;
848
+ } ) ;
849
+
850
+
851
+
801
852
describe ( 'min' , function ( ) {
802
853
beforeEach ( function ( ) {
803
854
compileInput ( '<input type="week" ng-model="value" name="alias" min="2013-W01" />' ) ;
@@ -846,30 +897,30 @@ describe('input', function() {
846
897
compileInput ( '<input type="datetime-local" ng-model="lunchtime"/>' ) ;
847
898
848
899
scope . $apply ( function ( ) {
849
- scope . lunchtime = '2013-12-16T11:30:15 ' ;
900
+ scope . lunchtime = '2013-12-16T11:30' ;
850
901
} ) ;
851
902
852
- expect ( inputElm . val ( ) ) . toBe ( '2013-12-16T11:30:15 ' ) ;
903
+ expect ( inputElm . val ( ) ) . toBe ( '2013-12-16T11:30' ) ;
853
904
} ) ;
854
905
855
906
it ( 'should set the view if the model if a valid Date object.' , function ( ) {
856
907
compileInput ( '<input type="datetime-local" ng-model="tenSecondsToNextYear"/>' ) ;
857
908
858
909
scope . $apply ( function ( ) {
859
- scope . tenSecondsToNextYear = new Date ( 2013 , 11 , 31 , 23 , 59 , 50 ) ;
910
+ scope . tenSecondsToNextYear = new Date ( 2013 , 11 , 31 , 23 , 59 ) ;
860
911
} ) ;
861
912
862
- expect ( inputElm . val ( ) ) . toBe ( '2013-12-31T23:59:50 ' ) ;
913
+ expect ( inputElm . val ( ) ) . toBe ( '2013-12-31T23:59' ) ;
863
914
} ) ;
864
915
865
916
it ( 'should set the model undefined if the view is invalid' , function ( ) {
866
917
compileInput ( '<input type="datetime-local" ng-model="breakMe"/>' ) ;
867
918
868
919
scope . $apply ( function ( ) {
869
- scope . breakMe = new Date ( 2009 , 0 , 6 , 16 , 25 , 10 ) ;
920
+ scope . breakMe = new Date ( 2009 , 0 , 6 , 16 , 25 ) ;
870
921
} ) ;
871
922
872
- expect ( inputElm . val ( ) ) . toBe ( '2009-01-06T16:25:10 ' ) ;
923
+ expect ( inputElm . val ( ) ) . toBe ( '2009-01-06T16:25' ) ;
873
924
874
925
try {
875
926
//set to text for browsers with datetime-local validation.
@@ -886,70 +937,70 @@ describe('input', function() {
886
937
887
938
describe ( 'min' , function ( ) {
888
939
beforeEach ( function ( ) {
889
- compileInput ( '<input type="datetime-local" ng-model="value" name="alias" min="2000-01-01T12:30:10 " />' ) ;
940
+ compileInput ( '<input type="datetime-local" ng-model="value" name="alias" min="2000-01-01T12:30" />' ) ;
890
941
scope . $digest ( ) ;
891
942
} ) ;
892
943
893
944
it ( 'should invalidate' , function ( ) {
894
- changeInputValueTo ( '1999-12-31T01:02:03 ' ) ;
945
+ changeInputValueTo ( '1999-12-31T01:02' ) ;
895
946
expect ( inputElm ) . toBeInvalid ( ) ;
896
947
expect ( scope . value ) . toBeFalsy ( ) ;
897
948
expect ( scope . form . alias . $error . min ) . toBeTruthy ( ) ;
898
949
} ) ;
899
950
900
951
it ( 'should validate' , function ( ) {
901
- changeInputValueTo ( '2000-01-01T23:02:01 ' ) ;
952
+ changeInputValueTo ( '2000-01-01T23:02' ) ;
902
953
expect ( inputElm ) . toBeValid ( ) ;
903
- expect ( + scope . value ) . toBe ( + new Date ( 2000 , 0 , 1 , 23 , 2 , 1 ) ) ;
954
+ expect ( + scope . value ) . toBe ( + new Date ( 2000 , 0 , 1 , 23 , 2 ) ) ;
904
955
expect ( scope . form . alias . $error . min ) . toBeFalsy ( ) ;
905
956
} ) ;
906
957
} ) ;
907
958
908
959
describe ( 'max' , function ( ) {
909
960
beforeEach ( function ( ) {
910
- compileInput ( '<input type="datetime-local" ng-model="value" name="alias" max="2019-01-01T01:02:03 " />' ) ;
961
+ compileInput ( '<input type="datetime-local" ng-model="value" name="alias" max="2019-01-01T01:02" />' ) ;
911
962
scope . $digest ( ) ;
912
963
} ) ;
913
964
914
965
it ( 'should invalidate' , function ( ) {
915
- changeInputValueTo ( '2019-12-31T01:02:03 ' ) ;
966
+ changeInputValueTo ( '2019-12-31T01:02' ) ;
916
967
expect ( inputElm ) . toBeInvalid ( ) ;
917
968
expect ( scope . value ) . toBeFalsy ( ) ;
918
969
expect ( scope . form . alias . $error . max ) . toBeTruthy ( ) ;
919
970
} ) ;
920
971
921
972
it ( 'should validate' , function ( ) {
922
- changeInputValueTo ( '2000-01-01T01:02:03 ' ) ;
973
+ changeInputValueTo ( '2000-01-01T01:02' ) ;
923
974
expect ( inputElm ) . toBeValid ( ) ;
924
- expect ( + scope . value ) . toBe ( + new Date ( 2000 , 0 , 1 , 1 , 2 , 3 ) ) ;
975
+ expect ( + scope . value ) . toBe ( + new Date ( 2000 , 0 , 1 , 1 , 2 ) ) ;
925
976
expect ( scope . form . alias . $error . max ) . toBeFalsy ( ) ;
926
977
} ) ;
927
978
} ) ;
928
979
929
980
it ( 'should validate even if max value changes on-the-fly' , function ( done ) {
930
- scope . max = '2013-01-01T01:02:03 ' ;
981
+ scope . max = '2013-01-01T01:02' ;
931
982
compileInput ( '<input type="datetime-local" ng-model="value" name="alias" max="{{max}}" />' ) ;
932
983
scope . $digest ( ) ;
933
984
934
- changeInputValueTo ( '2014-01-01T12:34:56 ' ) ;
985
+ changeInputValueTo ( '2014-01-01T12:34' ) ;
935
986
expect ( inputElm ) . toBeInvalid ( ) ;
936
987
937
- scope . max = '2001-01-01T01:02:03 ' ;
988
+ scope . max = '2001-01-01T01:02' ;
938
989
scope . $digest ( function ( ) {
939
990
expect ( inputElm ) . toBeValid ( ) ;
940
991
done ( ) ;
941
992
} ) ;
942
993
} ) ;
943
994
944
995
it ( 'should validate even if min value changes on-the-fly' , function ( done ) {
945
- scope . min = '2013-01-01T01:02:03 ' ;
996
+ scope . min = '2013-01-01T01:02' ;
946
997
compileInput ( '<input type="datetime-local" ng-model="value" name="alias" min="{{min}}" />' ) ;
947
998
scope . $digest ( ) ;
948
999
949
- changeInputValueTo ( '2010-01-01T12:34:56 ' ) ;
1000
+ changeInputValueTo ( '2010-01-01T12:34' ) ;
950
1001
expect ( inputElm ) . toBeInvalid ( ) ;
951
1002
952
- scope . min = '2014-01-01T01:02:03 ' ;
1003
+ scope . min = '2014-01-01T01:02' ;
953
1004
scope . $digest ( function ( ) {
954
1005
expect ( inputElm ) . toBeValid ( ) ;
955
1006
done ( ) ;
0 commit comments