@@ -556,6 +556,69 @@ describe( 'FindAndReplaceFormView', () => {
556
556
sinon . assert . calledOnceWithExactly ( spy , 'execute' ) ;
557
557
} ) ;
558
558
559
+ it ( 'handles "enter" when pressed in the find input and goes to the next result' , ( ) => {
560
+ const keyEvtData = {
561
+ keyCode : keyCodes . enter ,
562
+ preventDefault : sinon . spy ( ) ,
563
+ stopPropagation : sinon . spy ( ) ,
564
+ target : view . _findInputView . fieldView . element
565
+ } ;
566
+
567
+ view . _areCommandsEnabled = { findNext : true } ;
568
+
569
+ const spy = sinon . spy ( view . _findNextButtonView , 'fire' ) ;
570
+
571
+ view . _keystrokes . press ( keyEvtData ) ;
572
+
573
+ sinon . assert . calledOnce ( keyEvtData . preventDefault ) ;
574
+ sinon . assert . calledOnce ( keyEvtData . stopPropagation ) ;
575
+
576
+ sinon . assert . calledOnce ( spy ) ;
577
+ sinon . assert . calledOnceWithExactly ( spy , 'execute' ) ;
578
+ } ) ;
579
+
580
+ it ( 'handles "shift+enter" when pressed in the find input and performs a search' , ( ) => {
581
+ const keyEvtData = {
582
+ keyCode : keyCodes . enter ,
583
+ shiftKey : true ,
584
+ preventDefault : sinon . spy ( ) ,
585
+ stopPropagation : sinon . spy ( ) ,
586
+ target : view . _findInputView . fieldView . element
587
+ } ;
588
+
589
+ const spy = sinon . spy ( view . _findButtonView , 'fire' ) ;
590
+
591
+ view . _keystrokes . press ( keyEvtData ) ;
592
+
593
+ sinon . assert . calledOnce ( keyEvtData . preventDefault ) ;
594
+ sinon . assert . calledOnce ( keyEvtData . stopPropagation ) ;
595
+
596
+ sinon . assert . calledOnce ( spy ) ;
597
+ sinon . assert . calledOnceWithExactly ( spy , 'execute' ) ;
598
+ } ) ;
599
+
600
+ it ( 'handles "shift+enter" when pressed in the find input and goes to the previous result' , ( ) => {
601
+ const keyEvtData = {
602
+ keyCode : keyCodes . enter ,
603
+ shiftKey : true ,
604
+ preventDefault : sinon . spy ( ) ,
605
+ stopPropagation : sinon . spy ( ) ,
606
+ target : view . _findInputView . fieldView . element
607
+ } ;
608
+
609
+ view . _areCommandsEnabled = { findPrevious : true } ;
610
+
611
+ const spy = sinon . spy ( view . _findPrevButtonView , 'fire' ) ;
612
+
613
+ view . _keystrokes . press ( keyEvtData ) ;
614
+
615
+ sinon . assert . calledOnce ( keyEvtData . preventDefault ) ;
616
+ sinon . assert . calledOnce ( keyEvtData . stopPropagation ) ;
617
+
618
+ sinon . assert . calledOnce ( spy ) ;
619
+ sinon . assert . calledOnceWithExactly ( spy , 'execute' ) ;
620
+ } ) ;
621
+
559
622
it ( 'handles "enter" when pressed in the replace input and performs a replacement' , ( ) => {
560
623
const keyEvtData = {
561
624
keyCode : keyCodes . enter ,
@@ -590,6 +653,23 @@ describe( 'FindAndReplaceFormView', () => {
590
653
sinon . assert . notCalled ( keyEvtData . stopPropagation ) ;
591
654
sinon . assert . notCalled ( spy ) ;
592
655
} ) ;
656
+
657
+ it ( 'ignores "shift+enter" when pressed somewhere else' , ( ) => {
658
+ const keyEvtData = {
659
+ keyCode : keyCodes . enter ,
660
+ shiftKey : true ,
661
+ preventDefault : sinon . spy ( ) ,
662
+ stopPropagation : sinon . spy ( )
663
+ } ;
664
+
665
+ const spy = sinon . spy ( view . _replaceButtonView , 'fire' ) ;
666
+
667
+ view . _keystrokes . press ( keyEvtData ) ;
668
+
669
+ sinon . assert . notCalled ( keyEvtData . preventDefault ) ;
670
+ sinon . assert . notCalled ( keyEvtData . stopPropagation ) ;
671
+ sinon . assert . notCalled ( spy ) ;
672
+ } ) ;
593
673
} ) ;
594
674
} ) ;
595
675
0 commit comments