@@ -78,9 +78,7 @@ it('Moves the focus to the first menu item after pressing enter while focused on
7878
7979 expect ( screen . getByText ( 'Primary' ) ) . toHaveFocus ( ) ;
8080
81- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
82- skipClick : true ,
83- } ) ;
81+ await user . keyboard ( '{Enter}' ) ;
8482
8583 expect ( screen . getByText ( '1 Item' ) ) . toHaveFocus ( ) ;
8684} ) ;
@@ -92,9 +90,7 @@ it('Moves the focus to the first menu item after pressing space while focused on
9290
9391 expect ( screen . getByText ( 'Primary' ) ) . toHaveFocus ( ) ;
9492
95- await user . type ( screen . getByText ( 'Primary' ) , '{ }' , {
96- skipClick : true ,
97- } ) ;
93+ await user . keyboard ( '{ }' ) ;
9894
9995 expect ( screen . getByText ( '1 Item' ) ) . toHaveFocus ( ) ;
10096} ) ;
@@ -140,9 +136,7 @@ it('Sets isOpen to true after pressing enter while focused on the menu button',
140136
141137 expect ( screen . getByText ( 'Primary' ) ) . toHaveFocus ( ) ;
142138
143- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
144- skipClick : true ,
145- } ) ;
139+ await user . keyboard ( '{Enter}' ) ;
146140
147141 expect ( screen . getByTestId ( 'is-open-indicator' ) ) . toHaveTextContent ( 'true' ) ;
148142} ) ;
@@ -152,9 +146,7 @@ it('Sets isOpen to false after pressing escape while focused on the menu button'
152146
153147 await user . click ( screen . getByText ( 'Primary' ) ) ;
154148
155- await user . type ( screen . getByText ( 'Primary' ) , '{Escape}' , {
156- skipClick : true ,
157- } ) ;
149+ await user . keyboard ( '{Escape}' ) ;
158150
159151 expect ( screen . getByTestId ( 'is-open-indicator' ) ) . toHaveTextContent ( 'false' ) ;
160152} ) ;
@@ -168,9 +160,7 @@ it('Sets isOpen to true after pressing space while focused on the menu button',
168160
169161 expect ( screen . getByText ( 'Primary' ) ) . toHaveFocus ( ) ;
170162
171- await user . type ( screen . getByText ( 'Primary' ) , '{ }' , {
172- skipClick : true ,
173- } ) ;
163+ await user . keyboard ( '{ }' ) ;
174164
175165 expect ( screen . getByTestId ( 'is-open-indicator' ) ) . toHaveTextContent ( 'true' ) ;
176166} ) ;
@@ -189,9 +179,7 @@ it('Moves the focus to the next element in the menu after pressing the down arro
189179
190180 await user . tab ( ) ;
191181
192- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
193- skipClick : true ,
194- } ) ;
182+ await user . keyboard ( '{Enter}' ) ;
195183
196184 expect ( screen . getByText ( '1 Item' ) ) . toHaveFocus ( ) ;
197185
@@ -205,9 +193,7 @@ it('Moves the focus to the previous element in the menu after pressing the up ar
205193
206194 await user . tab ( ) ;
207195
208- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
209- skipClick : true ,
210- } ) ;
196+ await user . keyboard ( '{Enter}' ) ;
211197
212198 expect ( screen . getByText ( '1 Item' ) ) . toHaveFocus ( ) ;
213199
@@ -225,9 +211,7 @@ it('Wraps the focus to the last element when pressing the up arrow at the beginn
225211
226212 await user . tab ( ) ;
227213
228- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
229- skipClick : true ,
230- } ) ;
214+ await user . keyboard ( '{Enter}' ) ;
231215
232216 expect ( screen . getByText ( '1 Item' ) ) . toHaveFocus ( ) ;
233217
@@ -241,9 +225,7 @@ it('Wraps the focus to the first element when pressing the down arrow at the end
241225
242226 await user . tab ( ) ;
243227
244- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
245- skipClick : true ,
246- } ) ;
228+ await user . keyboard ( '{Enter}' ) ;
247229
248230 expect ( screen . getByText ( '1 Item' ) ) . toHaveFocus ( ) ;
249231
@@ -261,13 +243,9 @@ it('Sets isOpen to false after pressing escape while focused on a menu item', as
261243
262244 await user . tab ( ) ;
263245
264- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
265- skipClick : true ,
266- } ) ;
246+ await user . keyboard ( '{Enter}' ) ;
267247
268- await user . type ( screen . getByText ( '1 Item' ) , '{Escape}' , {
269- skipClick : true ,
270- } ) ;
248+ await user . keyboard ( '{Escape}' ) ;
271249
272250 expect ( screen . getByTestId ( 'is-open-indicator' ) ) . toHaveTextContent ( 'false' ) ;
273251} ) ;
@@ -277,9 +255,7 @@ it('Sets isOpen to false after pressing tab while focused on a menu item', async
277255
278256 await user . tab ( ) ;
279257
280- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
281- skipClick : true ,
282- } ) ;
258+ await user . keyboard ( '{Enter}' ) ;
283259
284260 await user . tab ( ) ;
285261
@@ -291,13 +267,9 @@ it('Moves the focus to the menu button after pressing escape while focused on a
291267
292268 await user . tab ( ) ;
293269
294- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
295- skipClick : true ,
296- } ) ;
270+ await user . keyboard ( '{Enter}' ) ;
297271
298- await user . type ( screen . getByText ( '1 Item' ) , '{Escape}' , {
299- skipClick : true ,
300- } ) ;
272+ await user . keyboard ( '{Escape}' ) ;
301273
302274 expect ( screen . getByText ( 'Primary' ) ) . toHaveFocus ( ) ;
303275} ) ;
@@ -348,23 +320,17 @@ it('Ignores keys that buttons don’t need to handle', async () => {
348320
349321 await user . tab ( ) ;
350322
351- await user . type ( screen . getByText ( 'Primary' ) , 'Z' , {
352- skipClick : true ,
353- } ) ;
323+ await user . keyboard ( 'Z' ) ;
354324} ) ;
355325
356326it ( 'Ignores keys that items don’t need to handle' , async ( ) => {
357327 const { user } = setup ( < TestComponent /> ) ;
358328
359329 await user . tab ( ) ;
360330
361- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
362- skipClick : true ,
363- } ) ;
331+ await user . keyboard ( '{Enter}' ) ;
364332
365- await user . type ( screen . getByText ( '1 Item' ) , 'Z' , {
366- skipClick : true ,
367- } ) ;
333+ await user . keyboard ( 'Z' ) ;
368334
369335 expect ( screen . getByText ( '1 Item' ) ) . toHaveFocus ( ) ;
370336} ) ;
@@ -374,27 +340,19 @@ it('Doesn’t crash when enter press occurs on a menu item', async () => {
374340
375341 await user . tab ( ) ;
376342
377- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
378- skipClick : true ,
379- } ) ;
343+ await user . keyboard ( '{Enter}' ) ;
380344
381- user . type ( screen . getByText ( '1 Item' ) , '{Enter}' , {
382- skipClick : true ,
383- } ) ;
345+ user . keyboard ( '{Enter}' ) ;
384346} ) ;
385347
386348it ( 'Closes the menu after pressing enter on a menu item with a click handler' , async ( ) => {
387349 const { user } = setup ( < TestComponent /> ) ;
388350
389351 await user . tab ( ) ;
390352
391- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
392- skipClick : true ,
393- } ) ;
353+ await user . keyboard ( '{Enter}' ) ;
394354
395- await user . type ( screen . getByText ( '1 Item' ) , '{Enter}' , {
396- skipClick : true ,
397- } ) ;
355+ await user . keyboard ( '{Enter}' ) ;
398356
399357 expect ( screen . getByTestId ( 'is-open-indicator' ) ) . toHaveTextContent ( 'false' ) ;
400358} ) ;
@@ -406,13 +364,9 @@ it('Activates the click handler of a menu item after pressing enter while focuse
406364
407365 await user . tab ( ) ;
408366
409- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
410- skipClick : true ,
411- } ) ;
367+ await user . keyboard ( '{Enter}' ) ;
412368
413- await user . type ( screen . getByText ( '1 Item' ) , '{Enter}' , {
414- skipClick : true ,
415- } ) ;
369+ await user . keyboard ( '{Enter}' ) ;
416370
417371 expect ( console . log ) . toHaveBeenCalledWith ( 'Item one clicked' ) ;
418372} ) ;
@@ -422,13 +376,9 @@ it('Closes the menu after pressing space on a menu item with a click handler', a
422376
423377 await user . tab ( ) ;
424378
425- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
426- skipClick : true ,
427- } ) ;
379+ await user . keyboard ( '{Enter}' ) ;
428380
429- await user . type ( screen . getByText ( '1 Item' ) , '{ }' , {
430- skipClick : true ,
431- } ) ;
381+ await user . keyboard ( '{ }' ) ;
432382
433383 expect ( screen . getByTestId ( 'is-open-indicator' ) ) . toHaveTextContent ( 'false' ) ;
434384} ) ;
@@ -440,13 +390,9 @@ it('Activates the click handler of a menu item after pressing space while focuse
440390
441391 await user . tab ( ) ;
442392
443- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
444- skipClick : true ,
445- } ) ;
393+ await user . keyboard ( '{Enter}' ) ;
446394
447- await user . type ( screen . getByText ( '1 Item' ) , '{ }' , {
448- skipClick : true ,
449- } ) ;
395+ await user . keyboard ( '{ }' ) ;
450396
451397 expect ( console . log ) . toHaveBeenCalledWith ( 'Item one clicked' ) ;
452398} ) ;
@@ -456,13 +402,9 @@ it('Moves the focus to the menu item with a label that starts with the correspon
456402
457403 await user . tab ( ) ;
458404
459- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
460- skipClick : true ,
461- } ) ;
405+ await user . keyboard ( '{Enter}' ) ;
462406
463- await user . type ( screen . getByText ( '1 Item' ) , '3' , {
464- skipClick : true ,
465- } ) ;
407+ await user . keyboard ( '3' ) ;
466408
467409 expect ( screen . getByText ( '3 Item' ) ) . toHaveFocus ( ) ;
468410} ) ;
@@ -472,9 +414,7 @@ it('Moves the focus to the provided menu item when `moveFocus` is called', async
472414
473415 await user . tab ( ) ;
474416
475- await user . type ( screen . getByText ( 'Primary' ) , '{Enter}' , {
476- skipClick : true ,
477- } ) ;
417+ await user . keyboard ( '{Enter}' ) ;
478418
479419 await user . click ( screen . getByTestId ( 'focus-third-item' ) ) ;
480420
0 commit comments