@@ -1918,6 +1918,83 @@ describe('input', function() {
1918
1918
} ) ;
1919
1919
} ) ;
1920
1920
1921
+ [ 'month' , 'week' , 'time' , 'date' , 'datetime-local' ] . forEach ( function ( inputType ) {
1922
+ if ( jqLite ( '<input type="' + inputType + '">' ) . attr ( 'type' ) !== inputType ) {
1923
+ return ;
1924
+ }
1925
+
1926
+ describe ( inputType , function ( ) {
1927
+ they ( 'should re-validate and dirty when partially editing the input value ($prop event)' ,
1928
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
1929
+ function ( validationEvent ) {
1930
+ var mockValidity = { valid : true , badInput : false } ;
1931
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" ng-model="val" name="alias" />' , mockValidity ) ;
1932
+
1933
+ expect ( inputElm ) . toBeValid ( ) ;
1934
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
1935
+
1936
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
1937
+ mockValidity . valid = false ;
1938
+ mockValidity . badInput = true ;
1939
+ $browser . defer . flush ( ) ;
1940
+ expect ( inputElm ) . toBeInvalid ( ) ;
1941
+ expect ( $rootScope . form . alias . $pristine ) . toBeFalsy ( ) ;
1942
+ }
1943
+ ) ;
1944
+
1945
+ they ( 'should do nothing when $prop event fired but validity does not change' ,
1946
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
1947
+ function ( validationEvent ) {
1948
+ var mockValidity = { valid : true , badInput : false } ;
1949
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" ng-model="val" name="alias" />' , mockValidity ) ;
1950
+
1951
+ expect ( inputElm ) . toBeValid ( ) ;
1952
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
1953
+
1954
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
1955
+ $browser . defer . flush ( ) ;
1956
+ expect ( inputElm ) . toBeValid ( ) ;
1957
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
1958
+ }
1959
+ ) ;
1960
+
1961
+ they ( 'should re-validate dirty when already $invalid and partially editing the input value ($prop event)' ,
1962
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
1963
+ function ( validationEvent ) {
1964
+ var mockValidity = { valid : false , valueMissing : true , badInput : false } ;
1965
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" required ng-model="val" name="alias" />' , mockValidity ) ;
1966
+
1967
+ expect ( inputElm ) . toBeInvalid ( ) ;
1968
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
1969
+
1970
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
1971
+ mockValidity . valid = false ;
1972
+ mockValidity . valueMissing = true ;
1973
+ mockValidity . badInput = true ;
1974
+ $browser . defer . flush ( ) ;
1975
+ expect ( inputElm ) . toBeInvalid ( ) ;
1976
+ expect ( $rootScope . form . alias . $pristine ) . toBeFalsy ( ) ;
1977
+ }
1978
+ ) ;
1979
+
1980
+ they ( 'should do nothing when already $invalid and $prop event fired but validity does not change' ,
1981
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
1982
+ function ( validationEvent ) {
1983
+ var mockValidity = { valid : false , valueMissing : true , badInput : false } ;
1984
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" required ng-model="val" name="alias" />' , mockValidity ) ;
1985
+
1986
+ expect ( inputElm ) . toBeInvalid ( ) ;
1987
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
1988
+
1989
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
1990
+ $browser . defer . flush ( ) ;
1991
+ expect ( inputElm ) . toBeInvalid ( ) ;
1992
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
1993
+ }
1994
+ ) ;
1995
+ } ) ;
1996
+ } ) ;
1997
+
1921
1998
1922
1999
describe ( 'number' , function ( ) {
1923
2000
0 commit comments