@@ -1943,6 +1943,83 @@ describe('input', function() {
1943
1943
} ) ;
1944
1944
} ) ;
1945
1945
1946
+ [ 'month' , 'week' , 'time' , 'date' , 'datetime-local' ] . forEach ( function ( inputType ) {
1947
+ if ( jqLite ( '<input type="' + inputType + '">' ) . prop ( 'type' ) !== inputType ) {
1948
+ return ;
1949
+ }
1950
+
1951
+ describe ( inputType , function ( ) {
1952
+ they ( 'should re-validate and dirty when partially editing the input value ($prop event)' ,
1953
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
1954
+ function ( validationEvent ) {
1955
+ var mockValidity = { valid : true , badInput : false } ;
1956
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" ng-model="val" name="alias" />' , mockValidity ) ;
1957
+
1958
+ expect ( inputElm ) . toBeValid ( ) ;
1959
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
1960
+
1961
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
1962
+ mockValidity . valid = false ;
1963
+ mockValidity . badInput = true ;
1964
+ $browser . defer . flush ( ) ;
1965
+ expect ( inputElm ) . toBeInvalid ( ) ;
1966
+ expect ( $rootScope . form . alias . $pristine ) . toBeFalsy ( ) ;
1967
+ }
1968
+ ) ;
1969
+
1970
+ they ( 'should do nothing when $prop event fired but validity does not change' ,
1971
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
1972
+ function ( validationEvent ) {
1973
+ var mockValidity = { valid : true , badInput : false } ;
1974
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" ng-model="val" name="alias" />' , mockValidity ) ;
1975
+
1976
+ expect ( inputElm ) . toBeValid ( ) ;
1977
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
1978
+
1979
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
1980
+ $browser . defer . flush ( ) ;
1981
+ expect ( inputElm ) . toBeValid ( ) ;
1982
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
1983
+ }
1984
+ ) ;
1985
+
1986
+ they ( 'should re-validate dirty when already $invalid and partially editing the input value ($prop event)' ,
1987
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
1988
+ function ( validationEvent ) {
1989
+ var mockValidity = { valid : false , valueMissing : true , badInput : false } ;
1990
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" required ng-model="val" name="alias" />' , mockValidity ) ;
1991
+
1992
+ expect ( inputElm ) . toBeInvalid ( ) ;
1993
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
1994
+
1995
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
1996
+ mockValidity . valid = false ;
1997
+ mockValidity . valueMissing = true ;
1998
+ mockValidity . badInput = true ;
1999
+ $browser . defer . flush ( ) ;
2000
+ expect ( inputElm ) . toBeInvalid ( ) ;
2001
+ expect ( $rootScope . form . alias . $pristine ) . toBeFalsy ( ) ;
2002
+ }
2003
+ ) ;
2004
+
2005
+ they ( 'should do nothing when already $invalid and $prop event fired but validity does not change' ,
2006
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
2007
+ function ( validationEvent ) {
2008
+ var mockValidity = { valid : false , valueMissing : true , badInput : false } ;
2009
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" required ng-model="val" name="alias" />' , mockValidity ) ;
2010
+
2011
+ expect ( inputElm ) . toBeInvalid ( ) ;
2012
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
2013
+
2014
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
2015
+ $browser . defer . flush ( ) ;
2016
+ expect ( inputElm ) . toBeInvalid ( ) ;
2017
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
2018
+ }
2019
+ ) ;
2020
+ } ) ;
2021
+ } ) ;
2022
+
1946
2023
1947
2024
describe ( 'number' , function ( ) {
1948
2025
0 commit comments