@@ -1931,6 +1931,50 @@ describe('MatAutocomplete', () => {
19311931 expect ( Math . ceil ( parseFloat ( overlayPane . style . width as string ) ) ) . toBe ( 400 ) ;
19321932 } ) ) ;
19331933
1934+ it ( 'should have panel width match host width by default' , ( ) => {
1935+ const widthFixture = createComponent ( SimpleAutocomplete ) ;
1936+
1937+ widthFixture . componentInstance . width = 300 ;
1938+ widthFixture . detectChanges ( ) ;
1939+
1940+ widthFixture . componentInstance . trigger . openPanel ( ) ;
1941+ widthFixture . detectChanges ( ) ;
1942+
1943+ const overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
1944+
1945+ expect ( Math . ceil ( parseFloat ( overlayPane . style . width as string ) ) ) . toBe ( 300 ) ;
1946+ } ) ;
1947+
1948+ it ( 'should have panel width set to string value' , ( ) => {
1949+ const widthFixture = createComponent ( SimpleAutocomplete ) ;
1950+
1951+ widthFixture . componentInstance . width = 300 ;
1952+ widthFixture . detectChanges ( ) ;
1953+
1954+ widthFixture . componentInstance . trigger . autocomplete . panelWidth = 'auto' ;
1955+ widthFixture . componentInstance . trigger . openPanel ( ) ;
1956+ widthFixture . detectChanges ( ) ;
1957+
1958+ const overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
1959+
1960+ expect ( overlayPane . style . width ) . toBe ( 'auto' ) ;
1961+ } ) ;
1962+
1963+ it ( 'should have panel width set to number value' , ( ) => {
1964+ const widthFixture = createComponent ( SimpleAutocomplete ) ;
1965+
1966+ widthFixture . componentInstance . width = 300 ;
1967+ widthFixture . detectChanges ( ) ;
1968+
1969+ widthFixture . componentInstance . trigger . autocomplete . panelWidth = 400 ;
1970+ widthFixture . componentInstance . trigger . openPanel ( ) ;
1971+ widthFixture . detectChanges ( ) ;
1972+
1973+ const overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
1974+
1975+ expect ( Math . ceil ( parseFloat ( overlayPane . style . width as string ) ) ) . toBe ( 400 ) ;
1976+ } ) ;
1977+
19341978 it ( 'should show the panel when the options are initialized later within a component with ' +
19351979 'OnPush change detection' , fakeAsync ( ( ) => {
19361980 let fixture = createComponent ( AutocompleteWithOnPushDelay ) ;
0 commit comments