8
0
Просмотр исходного кода

Tests: Added tests for WidgetTypeAround using an arrow with a Shift modifier.

Aleksander Nowodzinski 5 лет назад
Родитель
Сommit
289dac809b
1 измененных файлов с 32 добавлено и 0 удалено
  1. 32 0
      packages/ckeditor5-widget/tests/widgettypearound/widgettypearound.js

+ 32 - 0
packages/ckeditor5-widget/tests/widgettypearound/widgettypearound.js

@@ -357,6 +357,18 @@ describe( 'WidgetTypeAround', () => {
 				sinon.assert.calledOnce( domEventDataStub.domEvent.preventDefault );
 			} );
 
+			it( 'should activate if an arrow key is pressed along with Shift', () => {
+				setModelData( editor.model, '<paragraph>foo[]</paragraph><blockWidget></blockWidget>' );
+
+				fireKeyboardEvent( 'arrowright', { shiftKey: true } );
+
+				expect( getModelData( model ) ).to.equal( '<paragraph>foo</paragraph>[<blockWidget></blockWidget>]' );
+				expect( modelSelection.getAttribute( 'widget-type-around' ) ).to.equal( 'before' );
+
+				sinon.assert.calledOnce( eventInfoStub.stop );
+				sinon.assert.calledOnce( domEventDataStub.domEvent.preventDefault );
+			} );
+
 			it( 'should not activate when the selection is before the widget but the non-arrow key was pressed', () => {
 				setModelData( editor.model, '<paragraph>foo[]</paragraph><blockWidget></blockWidget>' );
 
@@ -508,6 +520,26 @@ describe( 'WidgetTypeAround', () => {
 				sinon.assert.calledOnce( domEventDataStub.domEvent.preventDefault );
 			} );
 
+			it( 'should deactivate if an arrow key is pressed along with Shift', () => {
+				setModelData( editor.model, '<paragraph>foo</paragraph>[<blockWidget></blockWidget>]' );
+
+				fireKeyboardEvent( 'arrowleft', { shiftKey: true } );
+
+				expect( getModelData( model ) ).to.equal( '<paragraph>foo</paragraph>[<blockWidget></blockWidget>]' );
+				expect( modelSelection.getAttribute( 'widget-type-around' ) ).to.equal( 'before' );
+
+				sinon.assert.calledOnce( eventInfoStub.stop );
+				sinon.assert.calledOnce( domEventDataStub.domEvent.preventDefault );
+
+				fireKeyboardEvent( 'arrowleft', { shiftKey: true } );
+
+				expect( getModelData( model ) ).to.equal( '<paragraph>foo[]</paragraph><blockWidget></blockWidget>' );
+				expect( modelSelection.getAttribute( 'widget-type-around' ) ).to.be.undefined;
+
+				sinon.assert.calledOnce( eventInfoStub.stop );
+				sinon.assert.calledOnce( domEventDataStub.domEvent.preventDefault );
+			} );
+
 			it( 'should not deactivate when the widget is selected and the navigation is backward but there is nowhere to go', () => {
 				setModelData( editor.model, '[<blockWidget></blockWidget>]' );