@@ -443,6 +443,78 @@ describe("Input general interaction", () => {
443
443
cy . get ( "@input" )
444
444
. should ( "have.prop" , "typedInValue" , "" ) ;
445
445
} ) ;
446
+
447
+ it ( "Should fire 'change' event once when clicking a suggestion equal to the typed value" , ( ) => {
448
+ const onChange = cy . spy ( ) . as ( "onChange" ) ;
449
+ const onSelectionChange = cy . spy ( ) . as ( "onSelectionChange" ) ;
450
+
451
+ cy . mount (
452
+ < Input
453
+ id = "input-equal-click"
454
+ showSuggestions
455
+ noTypeahead
456
+ onChange = { onChange }
457
+ onSelectionChange = { onSelectionChange }
458
+ >
459
+ < SuggestionItem text = "Cozy" />
460
+ < SuggestionItem text = "Compact" />
461
+ </ Input >
462
+ ) ;
463
+
464
+ cy . get ( "#input-equal-click" )
465
+ . shadow ( )
466
+ . find ( "input" )
467
+ . click ( )
468
+ . realType ( "Cozy" ) ;
469
+
470
+ cy . get ( "#input-equal-click" )
471
+ . shadow ( )
472
+ . find < ResponsivePopover > ( "[ui5-responsive-popover]" )
473
+ . ui5ResponsivePopoverOpened ( ) ;
474
+
475
+ cy . get ( '#input-equal-click' )
476
+ . find ( 'ui5-suggestion-item[text="Cozy"]' )
477
+ . click ( ) ;
478
+
479
+ cy . get ( "#input-equal-click" ) . should ( "have.value" , "Cozy" ) ;
480
+ cy . get ( "@onChange" ) . should ( "have.been.calledOnce" ) ;
481
+ } ) ;
482
+
483
+ it ( "Should fire 'change' event once when selecting a suggestion equal to the typed value with keyboard" , ( ) => {
484
+ const onChange = cy . spy ( ) . as ( "onChange" ) ;
485
+ const onSelectionChange = cy . spy ( ) . as ( "onSelectionChange" ) ;
486
+
487
+ cy . mount (
488
+ < Input
489
+ id = "input-equal-keyboard"
490
+ showSuggestions
491
+ noTypeahead
492
+ onChange = { onChange }
493
+ onSelectionChange = { onSelectionChange }
494
+ >
495
+ < SuggestionItem text = "Cozy" />
496
+ < SuggestionItem text = "Compact" />
497
+ </ Input >
498
+ ) ;
499
+
500
+ cy . get ( "#input-equal-keyboard" )
501
+ . shadow ( )
502
+ . find ( "input" )
503
+ . click ( )
504
+ . realType ( "Cozy" ) ;
505
+
506
+ cy . get ( "#input-equal-keyboard" )
507
+ . shadow ( )
508
+ . find < ResponsivePopover > ( "[ui5-responsive-popover]" )
509
+ . ui5ResponsivePopoverOpened ( ) ;
510
+
511
+ cy . realPress ( "ArrowDown" ) ;
512
+ cy . realPress ( "Enter" ) ;
513
+
514
+ cy . get ( "#input-equal-keyboard" ) . should ( "have.value" , "Cozy" ) ;
515
+ cy . get ( "@onChange" ) . should ( "have.been.calledOnce" ) ;
516
+ cy . get ( "@onSelectionChange" ) . should ( "have.been.calledOnce" ) ;
517
+ } ) ;
446
518
} ) ;
447
519
448
520
describe ( "Input arrow navigation" , ( ) => {
0 commit comments