@@ -1922,19 +1922,48 @@ describe('MatAutocomplete', () => {
1922
1922
expect ( Math . ceil ( parseFloat ( overlayPane . style . width as string ) ) ) . toBe ( 400 ) ;
1923
1923
} ) ) ;
1924
1924
1925
- it ( 'should have panel width set to auto' , ( ) => {
1926
- const widthFixture = createComponent ( SimpleAutocomplete ) ;
1925
+ it ( 'should have panel width match host width by default' , ( ) => {
1926
+ const widthFixture = createComponent ( SimpleAutocomplete ) ;
1927
+
1928
+ widthFixture . componentInstance . width = 300 ;
1929
+ widthFixture . detectChanges ( ) ;
1930
+
1931
+ widthFixture . componentInstance . trigger . openPanel ( ) ;
1932
+ widthFixture . detectChanges ( ) ;
1933
+
1934
+ const overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
1935
+
1936
+ expect ( Math . ceil ( parseFloat ( overlayPane . style . width as string ) ) ) . toBe ( 300 ) ;
1937
+ } ) ;
1938
+
1939
+ it ( 'should have panel width set to string value' , ( ) => {
1940
+ const widthFixture = createComponent ( SimpleAutocomplete ) ;
1941
+
1942
+ widthFixture . componentInstance . width = 300 ;
1943
+ widthFixture . detectChanges ( ) ;
1944
+
1945
+ widthFixture . componentInstance . trigger . autocomplete . panelWidth = 'auto' ;
1946
+ widthFixture . componentInstance . trigger . openPanel ( ) ;
1947
+ widthFixture . detectChanges ( ) ;
1948
+
1949
+ const overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
1950
+
1951
+ expect ( overlayPane . style . width ) . toBe ( 'auto' ) ;
1952
+ } ) ;
1927
1953
1928
- widthFixture . componentInstance . width = 300 ;
1929
- widthFixture . detectChanges ( ) ;
1954
+ it ( 'should have panel width set to number value' , ( ) => {
1955
+ const widthFixture = createComponent ( SimpleAutocomplete ) ;
1956
+
1957
+ widthFixture . componentInstance . width = 300 ;
1958
+ widthFixture . detectChanges ( ) ;
1930
1959
1931
- widthFixture . componentInstance . trigger . autocomplete . panelWidthAuto = true ;
1932
- widthFixture . componentInstance . trigger . openPanel ( ) ;
1933
- widthFixture . detectChanges ( ) ;
1960
+ widthFixture . componentInstance . trigger . autocomplete . panelWidth = 400 ;
1961
+ widthFixture . componentInstance . trigger . openPanel ( ) ;
1962
+ widthFixture . detectChanges ( ) ;
1934
1963
1935
- const overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
1964
+ const overlayPane = overlayContainerElement . querySelector ( '.cdk-overlay-pane' ) as HTMLElement ;
1936
1965
1937
- expect ( overlayPane . style . width ) . toBe ( 'auto' ) ;
1966
+ expect ( Math . ceil ( parseFloat ( overlayPane . style . width as string ) ) ) . toBe ( 400 ) ;
1938
1967
} ) ;
1939
1968
1940
1969
it ( 'should show the panel when the options are initialized later within a component with ' +
0 commit comments