@@ -931,7 +931,6 @@ it("works with fixed options excluded", () => {
931931} ) ;
932932
933933it ( "innerRef works correctly" , ( ) => {
934- const { simpleOptions } = generateOptions ( ) ;
935934 const name = faker . random . alpha ( 10 ) ;
936935 const options = generateOptions ( ) ;
937936
@@ -964,3 +963,39 @@ it("innerRef works correctly", () => {
964963 cy . get ( "button[title=focus]" ) . click ( ) ;
965964 cy . get ( `#${ name } ` ) . should ( "be.focused" ) ;
966965} ) ;
966+
967+ it ( "works with fitContentMenu" , ( ) => {
968+ const name = faker . random . alpha ( 10 ) ;
969+ const specificOptions = [
970+ { label : "A Very Long Movie Title That Exceeds Normal Lengths" , value : "1" } ,
971+ { label : "The Lord of the Rings: The Return of the King" , value : "2" } ,
972+ ] ;
973+
974+ cy . mount (
975+ < div className = "p-4" >
976+ < Form
977+ onSubmit = { ( ) => {
978+ // Nothing to do
979+ } }
980+ >
981+ < AsyncTypeaheadInput
982+ style = { { width : 300 } }
983+ queryFn = { async ( query : string ) => await fetchMock ( specificOptions , query , true ) }
984+ name = { name }
985+ label = { name }
986+ fitMenuContent
987+ />
988+ </ Form >
989+ </ div > ,
990+ ) ;
991+
992+ cy . get ( `#${ name } ` ) . click ( ) ;
993+ cy . focused ( ) . type ( specificOptions [ 0 ] . label ) ;
994+ cy . get ( ".MuiInputBase-root" ) . should ( "have.css" , "width" , "300px" ) ;
995+ cy . get ( "div[role='presentation']" ) . should ( ( $div ) => {
996+ const popperWidth = $div . width ( ) ?? 0 ;
997+ const paperWidth = $div . find ( "div.MuiPaper-root" ) . width ( ) ?? 0 ;
998+ expect ( paperWidth ) . to . be . equal ( popperWidth ) ;
999+ expect ( popperWidth ) . to . be . greaterThan ( 300 ) ;
1000+ } ) ;
1001+ } ) ;
0 commit comments