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

Tests: Added a test to verify 2-SCM acts properly when facing external changes.

Aleksander Nowodzinski 7 лет назад
Родитель
Сommit
9580ebb7da
1 измененных файлов с 18 добавлено и 0 удалено
  1. 18 0
      packages/ckeditor5-engine/tests/utils/bindtwostepcarettoattribute.js

+ 18 - 0
packages/ckeditor5-engine/tests/utils/bindtwostepcarettoattribute.js

@@ -461,6 +461,24 @@ describe( 'bindTwoStepCaretToAttribute()', () => {
 		expect( selection.isGravityOverridden ).to.false;
 	} );
 
+	it( 'should do nothing when the not a direct selection change but at the attribute boundary', () => {
+		setData( model, '<$text a="true">foo[]</$text>bar' );
+
+		testTwoStepCaretMovement( [
+			{ selectionAttributes: [ 'a' ], isGravityOverridden: false, preventDefault: 0 },
+			'→',
+			{ selectionAttributes: [], isGravityOverridden: true, preventDefault: 1 },
+		] );
+
+		// Simulate an external text insertion BEFORE the user selection to trigger #change:range.
+		model.enqueueChange( 'transparent', writer => {
+			writer.insertText( 'x', selection.getFirstPosition().getShiftedBy( -2 ) );
+		} );
+
+		expect( selection.isGravityOverridden ).to.true;
+		expect( getSelectionAttributesArray( selection ) ).to.have.members( [] );
+	} );
+
 	const keyMap = {
 		'→': 'arrowright',
 		'←': 'arrowleft'