@@ -443,6 +443,212 @@ test('{enter} on a button', () => {
443
443
` )
444
444
} )
445
445
446
+ test ( '{space} on a button' , ( ) => {
447
+ const { element, getEventSnapshot} = setup ( '<button />' )
448
+
449
+ userEvent . type ( element , '{space}' )
450
+
451
+ expect ( getEventSnapshot ( ) ) . toMatchInlineSnapshot ( `
452
+ Events fired on: button
453
+
454
+ button - pointerover
455
+ button - pointerenter
456
+ button - mouseover: Left (0)
457
+ button - mouseenter: Left (0)
458
+ button - pointermove
459
+ button - mousemove: Left (0)
460
+ button - pointerdown
461
+ button - mousedown: Left (0)
462
+ button - focus
463
+ button - focusin
464
+ button - pointerup
465
+ button - mouseup: Left (0)
466
+ button - click: Left (0)
467
+ button - keydown: (32)
468
+ button - keypress: (32)
469
+ button - keyup: (32)
470
+ button - click: Left (0)
471
+ ` )
472
+ } )
473
+
474
+ test ( '{space} with preventDefault keydown on button' , ( ) => {
475
+ const { element, getEventSnapshot} = setup ( '<button />' , {
476
+ eventHandlers : {
477
+ keyDown : e => e . preventDefault ( ) ,
478
+ } ,
479
+ } )
480
+
481
+ userEvent . type ( element , '{space}' )
482
+
483
+ expect ( getEventSnapshot ( ) ) . toMatchInlineSnapshot ( `
484
+ Events fired on: button
485
+
486
+ button - pointerover
487
+ button - pointerenter
488
+ button - mouseover: Left (0)
489
+ button - mouseenter: Left (0)
490
+ button - pointermove
491
+ button - mousemove: Left (0)
492
+ button - pointerdown
493
+ button - mousedown: Left (0)
494
+ button - focus
495
+ button - focusin
496
+ button - pointerup
497
+ button - mouseup: Left (0)
498
+ button - click: Left (0)
499
+ button - keydown: (32)
500
+ button - keyup: (32)
501
+ button - click: Left (0)
502
+ ` )
503
+ } )
504
+
505
+ test ( `' ' on a button` , ( ) => {
506
+ const { element, getEventSnapshot} = setup ( '<button />' )
507
+
508
+ userEvent . type ( element , ' ' )
509
+
510
+ expect ( getEventSnapshot ( ) ) . toMatchInlineSnapshot ( `
511
+ Events fired on: button
512
+
513
+ button - pointerover
514
+ button - pointerenter
515
+ button - mouseover: Left (0)
516
+ button - mouseenter: Left (0)
517
+ button - pointermove
518
+ button - mousemove: Left (0)
519
+ button - pointerdown
520
+ button - mousedown: Left (0)
521
+ button - focus
522
+ button - focusin
523
+ button - pointerup
524
+ button - mouseup: Left (0)
525
+ button - click: Left (0)
526
+ button - keydown: (32)
527
+ button - keypress: (32)
528
+ button - keyup: (32)
529
+ button - click: Left (0)
530
+ ` )
531
+ } )
532
+
533
+ test ( '{space} on an input' , ( ) => {
534
+ const { element, getEventSnapshot} = setup ( `<input value="" />` )
535
+
536
+ userEvent . type ( element , '{space}' )
537
+
538
+ expect ( getEventSnapshot ( ) ) . toMatchInlineSnapshot ( `
539
+ Events fired on: input[value=" "]
540
+
541
+ input[value=""] - pointerover
542
+ input[value=""] - pointerenter
543
+ input[value=""] - mouseover: Left (0)
544
+ input[value=""] - mouseenter: Left (0)
545
+ input[value=""] - pointermove
546
+ input[value=""] - mousemove: Left (0)
547
+ input[value=""] - pointerdown
548
+ input[value=""] - mousedown: Left (0)
549
+ input[value=""] - focus
550
+ input[value=""] - focusin
551
+ input[value=""] - pointerup
552
+ input[value=""] - mouseup: Left (0)
553
+ input[value=""] - click: Left (0)
554
+ input[value=""] - keydown: (32)
555
+ input[value=""] - keypress: (32)
556
+ input[value=" "] - input
557
+ "{CURSOR}" -> " {CURSOR}"
558
+ input[value=" "] - keyup: (32)
559
+ ` )
560
+ } )
561
+
562
+ test ( '{enter} on an input type="color"' , ( ) => {
563
+ const { element, getEventSnapshot} = setup (
564
+ `<input value="#ffffff" type="color" />` ,
565
+ )
566
+
567
+ userEvent . type ( element , '{enter}' )
568
+
569
+ expect ( getEventSnapshot ( ) ) . toMatchInlineSnapshot ( `
570
+ Events fired on: input[value="#ffffff"]
571
+
572
+ input[value="#ffffff"] - pointerover
573
+ input[value="#ffffff"] - pointerenter
574
+ input[value="#ffffff"] - mouseover: Left (0)
575
+ input[value="#ffffff"] - mouseenter: Left (0)
576
+ input[value="#ffffff"] - pointermove
577
+ input[value="#ffffff"] - mousemove: Left (0)
578
+ input[value="#ffffff"] - pointerdown
579
+ input[value="#ffffff"] - mousedown: Left (0)
580
+ input[value="#ffffff"] - focus
581
+ input[value="#ffffff"] - focusin
582
+ input[value="#ffffff"] - pointerup
583
+ input[value="#ffffff"] - mouseup: Left (0)
584
+ input[value="#ffffff"] - click: Left (0)
585
+ input[value="#ffffff"] - keydown: Enter (13)
586
+ input[value="#ffffff"] - keypress: Enter (13)
587
+ input[value="#ffffff"] - click: Left (0)
588
+ input[value="#ffffff"] - keyup: Enter (13)
589
+ ` )
590
+ } )
591
+
592
+ test ( '{space} on an input type="color"' , ( ) => {
593
+ const { element, getEventSnapshot} = setup (
594
+ `<input value="#ffffff" type="color" />` ,
595
+ )
596
+
597
+ userEvent . type ( element , '{space}' )
598
+
599
+ expect ( getEventSnapshot ( ) ) . toMatchInlineSnapshot ( `
600
+ Events fired on: input[value="#ffffff"]
601
+
602
+ input[value="#ffffff"] - pointerover
603
+ input[value="#ffffff"] - pointerenter
604
+ input[value="#ffffff"] - mouseover: Left (0)
605
+ input[value="#ffffff"] - mouseenter: Left (0)
606
+ input[value="#ffffff"] - pointermove
607
+ input[value="#ffffff"] - mousemove: Left (0)
608
+ input[value="#ffffff"] - pointerdown
609
+ input[value="#ffffff"] - mousedown: Left (0)
610
+ input[value="#ffffff"] - focus
611
+ input[value="#ffffff"] - focusin
612
+ input[value="#ffffff"] - pointerup
613
+ input[value="#ffffff"] - mouseup: Left (0)
614
+ input[value="#ffffff"] - click: Left (0)
615
+ input[value="#ffffff"] - keydown: (32)
616
+ input[value="#ffffff"] - keypress: (32)
617
+ input[value="#ffffff"] - keyup: (32)
618
+ input[value="#ffffff"] - click: Left (0)
619
+ ` )
620
+ } )
621
+
622
+ test ( '" " on an input type="color"' , ( ) => {
623
+ const { element, getEventSnapshot} = setup (
624
+ `<input value="#ffffff" type="color" />` ,
625
+ )
626
+
627
+ userEvent . type ( element , ' ' )
628
+
629
+ expect ( getEventSnapshot ( ) ) . toMatchInlineSnapshot ( `
630
+ Events fired on: input[value="#ffffff"]
631
+
632
+ input[value="#ffffff"] - pointerover
633
+ input[value="#ffffff"] - pointerenter
634
+ input[value="#ffffff"] - mouseover: Left (0)
635
+ input[value="#ffffff"] - mouseenter: Left (0)
636
+ input[value="#ffffff"] - pointermove
637
+ input[value="#ffffff"] - mousemove: Left (0)
638
+ input[value="#ffffff"] - pointerdown
639
+ input[value="#ffffff"] - mousedown: Left (0)
640
+ input[value="#ffffff"] - focus
641
+ input[value="#ffffff"] - focusin
642
+ input[value="#ffffff"] - pointerup
643
+ input[value="#ffffff"] - mouseup: Left (0)
644
+ input[value="#ffffff"] - click: Left (0)
645
+ input[value="#ffffff"] - keydown: (32)
646
+ input[value="#ffffff"] - keypress: (32)
647
+ input[value="#ffffff"] - keyup: (32)
648
+ input[value="#ffffff"] - click: Left (0)
649
+ ` )
650
+ } )
651
+
446
652
test ( '{enter} on a textarea' , ( ) => {
447
653
const { element, getEventSnapshot} = setup ( '<textarea></textarea>' )
448
654
0 commit comments