@@ -845,15 +845,26 @@ describe( 'LinkUI', () => {
845845 expect ( focusEditableSpy . calledOnce ) . to . be . true ;
846846 } ) ;
847847
848- it ( 'should hide and reveal the #actionsView on formView#cancel event' , ( ) => {
848+ it ( 'should hide and reveal the #actionsView on formView#cancel event if link command has a value ' , ( ) => {
849849 linkUIFeature . _showUI ( ) ;
850+
851+ const command = editor . commands . get ( 'link' ) ;
852+ command . value = 'http://foo.com' ;
853+
850854 formView . fire ( 'cancel' ) ;
851855
852856 expect ( balloon . visibleView ) . to . equal ( actionsView ) ;
853857 expect ( focusEditableSpy . calledOnce ) . to . be . true ;
854858 } ) ;
855859
856- it ( 'should hide after Esc key press' , ( ) => {
860+ it ( 'should hide the balloon on formView#cancel if link command does not have a value' , ( ) => {
861+ linkUIFeature . _showUI ( ) ;
862+ formView . fire ( 'cancel' ) ;
863+
864+ expect ( balloon . visibleView ) . to . be . null ;
865+ } ) ;
866+
867+ it ( 'should hide and reveal the #actionsView after Esc key press if link command has a value' , ( ) => {
857868 const keyEvtData = {
858869 keyCode : keyCodes . esc ,
859870 preventDefault : sinon . spy ( ) ,
@@ -862,11 +873,29 @@ describe( 'LinkUI', () => {
862873
863874 linkUIFeature . _showUI ( ) ;
864875
876+ const command = editor . commands . get ( 'link' ) ;
877+ command . value = 'http://foo.com' ;
878+
865879 formView . keystrokes . press ( keyEvtData ) ;
880+
866881 expect ( balloon . visibleView ) . to . equal ( actionsView ) ;
867882 expect ( focusEditableSpy . calledOnce ) . to . be . true ;
868883 } ) ;
869884
885+ it ( 'should hide the balloon after Esc key press if link command does not have a value' , ( ) => {
886+ const keyEvtData = {
887+ keyCode : keyCodes . esc ,
888+ preventDefault : sinon . spy ( ) ,
889+ stopPropagation : sinon . spy ( )
890+ } ;
891+
892+ linkUIFeature . _showUI ( ) ;
893+
894+ formView . keystrokes . press ( keyEvtData ) ;
895+
896+ expect ( balloon . visibleView ) . to . be . null ;
897+ } ) ;
898+
870899 // https://github.com/ckeditor/ckeditor5/issues/1501
871900 it ( 'should blur url input element before hiding the view' , ( ) => {
872901 linkUIFeature . _showUI ( ) ;
0 commit comments