@@ -180,6 +180,28 @@ describe('FocusOriginMonitor', () => {
180
180
expect ( changeHandler ) . toHaveBeenCalledWith ( 'program' ) ;
181
181
} , 0 ) ;
182
182
} ) ) ;
183
+
184
+ it ( 'should remove focus classes on blur' , async ( ( ) => {
185
+ if ( platform . FIREFOX ) { return ; }
186
+
187
+ buttonElement . focus ( ) ;
188
+ fixture . detectChanges ( ) ;
189
+
190
+ setTimeout ( ( ) => {
191
+ fixture . detectChanges ( ) ;
192
+
193
+ expect ( buttonElement . classList . length )
194
+ . toBe ( 2 , 'button should have exactly 2 focus classes' ) ;
195
+ expect ( changeHandler ) . toHaveBeenCalledWith ( 'program' ) ;
196
+
197
+ buttonElement . blur ( ) ;
198
+ fixture . detectChanges ( ) ;
199
+
200
+ expect ( buttonElement . classList . length )
201
+ . toBe ( 0 , 'button should not have any focus classes' ) ;
202
+ expect ( changeHandler ) . toHaveBeenCalledWith ( null ) ;
203
+ } , 0 ) ;
204
+ } ) ) ;
183
205
} ) ;
184
206
185
207
@@ -275,6 +297,28 @@ describe('cdkFocusClasses', () => {
275
297
expect ( changeHandler ) . toHaveBeenCalledWith ( 'program' ) ;
276
298
} , 0 ) ;
277
299
} ) ) ;
300
+
301
+ it ( 'should remove focus classes on blur' , async ( ( ) => {
302
+ if ( platform . FIREFOX ) { return ; }
303
+
304
+ buttonElement . focus ( ) ;
305
+ fixture . detectChanges ( ) ;
306
+
307
+ setTimeout ( ( ) => {
308
+ fixture . detectChanges ( ) ;
309
+
310
+ expect ( buttonElement . classList . length )
311
+ . toBe ( 2 , 'button should have exactly 2 focus classes' ) ;
312
+ expect ( changeHandler ) . toHaveBeenCalledWith ( 'program' ) ;
313
+
314
+ buttonElement . blur ( ) ;
315
+ fixture . detectChanges ( ) ;
316
+
317
+ expect ( buttonElement . classList . length )
318
+ . toBe ( 0 , 'button should not have any focus classes' ) ;
319
+ expect ( changeHandler ) . toHaveBeenCalledWith ( null ) ;
320
+ } , 0 ) ;
321
+ } ) ) ;
278
322
} ) ;
279
323
280
324
0 commit comments