@@ -161,14 +161,58 @@ describe("SuggestBox", () => {
161161 expect ( screen . getByRole ( "option" ) ) . toHaveTextContent ( "Parameter[1]" ) ;
162162 } ) ;
163163
164- it ( "closes the options when selecting an option" , async ( ) => {
164+ it ( "selects an option using Enter " , async ( ) => {
165165 render ( {
166166 value : "Argument[block].1" ,
167167 } ) ;
168168
169169 await userEvent . click ( screen . getByRole ( "combobox" ) ) ;
170170 await userEvent . keyboard ( "{Enter}" ) ;
171171
172+ expect ( onChange ) . toHaveBeenCalledWith ( "Argument[block].Parameter[1]" ) ;
173+ } ) ;
174+
175+ it ( "selects an option using Tab" , async ( ) => {
176+ render ( {
177+ value : "Argument[block].1" ,
178+ } ) ;
179+
180+ await userEvent . click ( screen . getByRole ( "combobox" ) ) ;
181+ await userEvent . keyboard ( "{Enter}" ) ;
182+
183+ expect ( onChange ) . toHaveBeenCalledWith ( "Argument[block].Parameter[1]" ) ;
184+ } ) ;
185+
186+ it ( "does not select an option using Home" , async ( ) => {
187+ render ( {
188+ value : "Argument[block].1" ,
189+ } ) ;
190+
191+ await userEvent . click ( screen . getByRole ( "combobox" ) ) ;
192+ await userEvent . keyboard ( "{Home}" ) ;
193+
194+ expect ( onChange ) . not . toHaveBeenCalled ( ) ;
195+ } ) ;
196+
197+ it ( "closes the options when selecting an option using Enter" , async ( ) => {
198+ render ( {
199+ value : "Argument[block].1" ,
200+ } ) ;
201+
202+ await userEvent . click ( screen . getByRole ( "combobox" ) ) ;
203+ await userEvent . keyboard ( "{Enter}" ) ;
204+
205+ expect ( screen . queryByRole ( "option" ) ) . not . toBeInTheDocument ( ) ;
206+ } ) ;
207+
208+ it ( "closes the options when selecting an option using Tab" , async ( ) => {
209+ render ( {
210+ value : "Argument[block].1" ,
211+ } ) ;
212+
213+ await userEvent . click ( screen . getByRole ( "combobox" ) ) ;
214+ await userEvent . keyboard ( "{Tab}" ) ;
215+
172216 expect ( screen . queryByRole ( "option" ) ) . not . toBeInTheDocument ( ) ;
173217 } ) ;
174218
0 commit comments