Explorar el Código

Add test cases.

Maciej Gołaszewski hace 6 años
padre
commit
bd34506606

+ 30 - 8
packages/ckeditor5-restricted-editing/tests/restrictededitingmodeediting.js

@@ -619,19 +619,41 @@ describe( 'RestrictedEditingModeEditing', () => {
 				assertEqualMarkup( getModelData( model ), '<paragraph>foo []bar baz</paragraph>' );
 			} );
 
-			it( 'should cut selected content inside exception marker', () => {
-				setModelData( model, '<paragraph>[]foo bar baz</paragraph>' );
+			it( 'should cut selected content inside exception marker (selection inside marker)', () => {
+				setModelData( model, '<paragraph>foo b[a]r baz</paragraph>' );
 				const firstParagraph = model.document.getRoot().getChild( 0 );
+				addExceptionMarker( 4, 7, firstParagraph, 1 );
 
+				viewDoc.fire( 'clipboardOutput', {
+					content: {
+						isEmpty: true
+					},
+					method: 'cut'
+				} );
+
+				assertEqualMarkup( getModelData( model ), '<paragraph>foo b[]r baz</paragraph>' );
+			} );
+
+			it( 'should cut selected content inside exception marker (selection touching marker start)', () => {
+				setModelData( model, '<paragraph>foo [ba]r baz</paragraph>' );
+				const firstParagraph = model.document.getRoot().getChild( 0 );
 				addExceptionMarker( 4, 7, firstParagraph, 1 );
 
-				model.change( writer => {
-					writer.setSelection( writer.createRange(
-						writer.createPositionAt( firstParagraph, 5 ),
-						writer.createPositionAt( firstParagraph, 6 )
-					) );
+				viewDoc.fire( 'clipboardOutput', {
+					content: {
+						isEmpty: true
+					},
+					method: 'cut'
 				} );
 
+				assertEqualMarkup( getModelData( model ), '<paragraph>foo []r baz</paragraph>' );
+			} );
+
+			it( 'should cut selected content inside exception marker (selection touching marker end)', () => {
+				setModelData( model, '<paragraph>foo b[ar] baz</paragraph>' );
+				const firstParagraph = model.document.getRoot().getChild( 0 );
+				addExceptionMarker( 4, 7, firstParagraph, 1 );
+
 				viewDoc.fire( 'clipboardOutput', {
 					content: {
 						isEmpty: true
@@ -639,7 +661,7 @@ describe( 'RestrictedEditingModeEditing', () => {
 					method: 'cut'
 				} );
 
-				assertEqualMarkup( getModelData( model ), '<paragraph>foo b[]r baz</paragraph>' );
+				assertEqualMarkup( getModelData( model ), '<paragraph>foo b[] baz</paragraph>' );
 			} );
 		} );