@@ -158,6 +158,28 @@ describe('FocusOriginMonitor', () => {
158
158
expect ( changeHandler ) . toHaveBeenCalledWith ( 'program' ) ;
159
159
} , 0 ) ;
160
160
} ) ) ;
161
+
162
+ it ( 'should remove focus classes on blur' , async ( ( ) => {
163
+ if ( platform . FIREFOX ) { return ; }
164
+
165
+ buttonElement . focus ( ) ;
166
+ fixture . detectChanges ( ) ;
167
+
168
+ setTimeout ( ( ) => {
169
+ fixture . detectChanges ( ) ;
170
+
171
+ expect ( buttonElement . classList . length )
172
+ . toBe ( 2 , 'button should have exactly 2 focus classes' ) ;
173
+ expect ( changeHandler ) . toHaveBeenCalledWith ( 'program' ) ;
174
+
175
+ buttonElement . blur ( ) ;
176
+ fixture . detectChanges ( ) ;
177
+
178
+ expect ( buttonElement . classList . length )
179
+ . toBe ( 0 , 'button should not have any focus classes' ) ;
180
+ expect ( changeHandler ) . toHaveBeenCalledWith ( null ) ;
181
+ } , 0 ) ;
182
+ } ) ) ;
161
183
} ) ;
162
184
163
185
@@ -248,6 +270,28 @@ describe('cdkFocusClasses', () => {
248
270
expect ( changeHandler ) . toHaveBeenCalledWith ( 'program' ) ;
249
271
} , 0 ) ;
250
272
} ) ) ;
273
+
274
+ it ( 'should remove focus classes on blur' , async ( ( ) => {
275
+ if ( platform . FIREFOX ) { return ; }
276
+
277
+ buttonElement . focus ( ) ;
278
+ fixture . detectChanges ( ) ;
279
+
280
+ setTimeout ( ( ) => {
281
+ fixture . detectChanges ( ) ;
282
+
283
+ expect ( buttonElement . classList . length )
284
+ . toBe ( 2 , 'button should have exactly 2 focus classes' ) ;
285
+ expect ( changeHandler ) . toHaveBeenCalledWith ( 'program' ) ;
286
+
287
+ buttonElement . blur ( ) ;
288
+ fixture . detectChanges ( ) ;
289
+
290
+ expect ( buttonElement . classList . length )
291
+ . toBe ( 0 , 'button should not have any focus classes' ) ;
292
+ expect ( changeHandler ) . toHaveBeenCalledWith ( null ) ;
293
+ } , 0 ) ;
294
+ } ) ) ;
251
295
} ) ;
252
296
253
297
0 commit comments