@@ -3014,6 +3014,66 @@ describe('MatAutocomplete', () => {
30143014 } ) ;
30153015 } ) ;
30163016
3017+ describe ( 'with backdrop in default options' , ( ) => {
3018+ it ( 'should contain backdrop by default' , fakeAsync ( ( ) => {
3019+ const fixture = createComponent ( SimpleAutocomplete , [ ] ) ;
3020+ fixture . detectChanges ( ) ;
3021+ fixture . componentInstance . trigger . openPanel ( ) ;
3022+ fixture . detectChanges ( ) ;
3023+
3024+ tick ( 500 ) ;
3025+
3026+ expect ( overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) ) . toBeTruthy ( ) ;
3027+ } ) ) ;
3028+
3029+ it ( 'should be able to remove the backdrop' , fakeAsync ( ( ) => {
3030+ const fixture = createComponent ( SimpleAutocomplete , [
3031+ {
3032+ provide : MAT_AUTOCOMPLETE_DEFAULT_OPTIONS ,
3033+ useValue : { hasBackdrop : false } ,
3034+ } ,
3035+ ] ) ;
3036+ fixture . detectChanges ( ) ;
3037+ fixture . componentInstance . trigger . openPanel ( ) ;
3038+ fixture . detectChanges ( ) ;
3039+
3040+ tick ( 500 ) ;
3041+
3042+ expect ( overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) ) . toBeFalsy ( ) ;
3043+ } ) ) ;
3044+ } ) ;
3045+
3046+ describe ( 'with backdropClass in default options' , ( ) => {
3047+ it ( 'should contain default backdropClass' , fakeAsync ( ( ) => {
3048+ const fixture = createComponent ( SimpleAutocomplete , [ ] ) ;
3049+ fixture . detectChanges ( ) ;
3050+ fixture . componentInstance . trigger . openPanel ( ) ;
3051+ fixture . detectChanges ( ) ;
3052+
3053+ tick ( 500 ) ;
3054+
3055+ const cdkPanelElement = overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) ;
3056+ expect ( cdkPanelElement ?. classList ) . toContain ( 'cdk-overlay-transparent-backdrop' ) ;
3057+ } ) ) ;
3058+
3059+ it ( 'should be able to remove the backdrop' , fakeAsync ( ( ) => {
3060+ const fixture = createComponent ( SimpleAutocomplete , [
3061+ {
3062+ provide : MAT_AUTOCOMPLETE_DEFAULT_OPTIONS ,
3063+ useValue : { backdropClass : 'my-custom-backdrop-class' , hasBackdrop : true } ,
3064+ } ,
3065+ ] ) ;
3066+ fixture . detectChanges ( ) ;
3067+ fixture . componentInstance . trigger . openPanel ( ) ;
3068+ fixture . detectChanges ( ) ;
3069+
3070+ tick ( 500 ) ;
3071+
3072+ const cdkPanelElement = overlayContainerElement . querySelector ( '.cdk-overlay-backdrop' ) ;
3073+ expect ( cdkPanelElement ?. classList ) . toContain ( 'my-custom-backdrop-class' ) ;
3074+ } ) ) ;
3075+ } ) ;
3076+
30173077 describe ( 'misc' , ( ) => {
30183078 it ( 'should allow basic use without any forms directives' , ( ) => {
30193079 expect ( ( ) => {
0 commit comments