@@ -2103,6 +2103,83 @@ describe('input', function() {
2103
2103
} ) ;
2104
2104
} ) ;
2105
2105
2106
+ [ 'month' , 'week' , 'time' , 'date' , 'datetime-local' ] . forEach ( function ( inputType ) {
2107
+ if ( jqLite ( '<input type="' + inputType + '">' ) . prop ( 'type' ) !== inputType ) {
2108
+ return ;
2109
+ }
2110
+
2111
+ describe ( inputType , function ( ) {
2112
+ they ( 'should re-validate and dirty when partially editing the input value ($prop event)' ,
2113
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
2114
+ function ( validationEvent ) {
2115
+ var mockValidity = { valid : true , badInput : false } ;
2116
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" ng-model="val" name="alias" />' , mockValidity ) ;
2117
+
2118
+ expect ( inputElm ) . toBeValid ( ) ;
2119
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
2120
+
2121
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
2122
+ mockValidity . valid = false ;
2123
+ mockValidity . badInput = true ;
2124
+ $browser . defer . flush ( ) ;
2125
+ expect ( inputElm ) . toBeInvalid ( ) ;
2126
+ expect ( $rootScope . form . alias . $pristine ) . toBeFalsy ( ) ;
2127
+ }
2128
+ ) ;
2129
+
2130
+ they ( 'should do nothing when $prop event fired but validity does not change' ,
2131
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
2132
+ function ( validationEvent ) {
2133
+ var mockValidity = { valid : true , badInput : false } ;
2134
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" ng-model="val" name="alias" />' , mockValidity ) ;
2135
+
2136
+ expect ( inputElm ) . toBeValid ( ) ;
2137
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
2138
+
2139
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
2140
+ $browser . defer . flush ( ) ;
2141
+ expect ( inputElm ) . toBeValid ( ) ;
2142
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
2143
+ }
2144
+ ) ;
2145
+
2146
+ they ( 'should re-validate dirty when already $invalid and partially editing the input value ($prop event)' ,
2147
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
2148
+ function ( validationEvent ) {
2149
+ var mockValidity = { valid : false , valueMissing : true , badInput : false } ;
2150
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" required ng-model="val" name="alias" />' , mockValidity ) ;
2151
+
2152
+ expect ( inputElm ) . toBeInvalid ( ) ;
2153
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
2154
+
2155
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
2156
+ mockValidity . valid = false ;
2157
+ mockValidity . valueMissing = true ;
2158
+ mockValidity . badInput = true ;
2159
+ $browser . defer . flush ( ) ;
2160
+ expect ( inputElm ) . toBeInvalid ( ) ;
2161
+ expect ( $rootScope . form . alias . $pristine ) . toBeFalsy ( ) ;
2162
+ }
2163
+ ) ;
2164
+
2165
+ they ( 'should do nothing when already $invalid and $prop event fired but validity does not change' ,
2166
+ [ 'keydown' , 'wheel' , 'mousedown' ] ,
2167
+ function ( validationEvent ) {
2168
+ var mockValidity = { valid : false , valueMissing : true , badInput : false } ;
2169
+ var inputElm = helper . compileInput ( '<input type="' + inputType + '" required ng-model="val" name="alias" />' , mockValidity ) ;
2170
+
2171
+ expect ( inputElm ) . toBeInvalid ( ) ;
2172
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
2173
+
2174
+ inputElm . triggerHandler ( { type : validationEvent } ) ;
2175
+ $browser . defer . flush ( ) ;
2176
+ expect ( inputElm ) . toBeInvalid ( ) ;
2177
+ expect ( $rootScope . form . alias . $pristine ) . toBeTruthy ( ) ;
2178
+ }
2179
+ ) ;
2180
+ } ) ;
2181
+ } ) ;
2182
+
2106
2183
2107
2184
describe ( 'number' , function ( ) {
2108
2185
0 commit comments