浏览代码

Added: Test cases with a range inside a block.

Mgsy 7 年之前
父节点
当前提交
0cb4d4845a

+ 67 - 0
packages/ckeditor5-engine/tests/model/operation/transform/split.js

@@ -52,6 +52,40 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in same path', () => {
+				john.setData( '<paragraph>F[]oo</paragraph>' );
+				kate.setData( '<paragraph>[Foo]</paragraph>' );
+
+				john.split();
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				expectClients(
+					'<paragraph><div>F</div></paragraph>' +
+					'<paragraph><div>oo</div></paragraph>'
+				);
+			} );
+
+			it( 'text in same path, then undo', () => {
+				john.setData( '<paragraph>F[]oo</paragraph>' );
+				kate.setData( '<paragraph>[Foo]</paragraph>' );
+
+				john.split();
+				kate.wrap( 'div' );
+
+				syncClients();
+
+				kate.undo();
+
+				syncClients();
+
+				expectClients(
+					'<paragraph>F</paragraph>' +
+					'<paragraph>oo</paragraph>'
+				);
+			} );
+
 			it( 'multiple elements', () => {
 				john.setData( '<paragraph>F[]oo</paragraph><paragraph>Bar</paragraph>' );
 				kate.setData( '[<paragraph>Foo</paragraph><paragraph>Bar</paragraph>]' );
@@ -122,6 +156,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in same path', () => {
+				john.setData( '<blockQuote><paragraph>F[]oo</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.split();
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<blockQuote>F</blockQuote>' +
+					'<blockQuote>oo</blockQuote>'
+				);
+			} );
+
 			it.skip( 'element in same position', () => {
 				john.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );
 				kate.setData( '<blockQuote><paragraph>[]Foo</paragraph></blockQuote>' );
@@ -152,6 +201,24 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in same path, then undo', () => {
+				john.setData( '<blockQuote><paragraph>F[]oo</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.split();
+				kate.unwrap();
+
+				syncClients();
+
+				john.undo();
+
+				syncClients();
+
+				expectClients(
+					'<blockQuote>Foo</blockQuote>'
+				);
+			} );
+
 			it( 'multiple elements', () => {
 				john.setData( '<blockQuote><paragraph>F[]oo</paragraph><paragraph>Bar</paragraph></blockQuote>' );
 				kate.setData( '<blockQuote>[<paragraph>Foo</paragraph><paragraph>Bar</paragraph>]</blockQuote>' );

+ 51 - 1
packages/ckeditor5-engine/tests/model/operation/transform/unwrap.js

@@ -38,6 +38,28 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData(
+					'<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' +
+					'<blockQuote><paragraph>Bar</paragraph></blockQuote>'
+				);
+
+				kate.setData(
+					'<blockQuote><paragraph>Foo</paragraph></blockQuote>' +
+					'<blockQuote><paragraph>[Bar]</paragraph></blockQuote>'
+				);
+
+				john.unwrap();
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<blockQuote>Foo</blockQuote>' +
+					'<blockQuote>Bar</blockQuote>'
+				);
+			} );
+
 			it( 'the same element', () => {
 				john.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
 				kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
@@ -68,10 +90,38 @@ describe( 'transform', () => {
 				// Kate has a different order of nodes in graveyard after syncing.
 				expectClients( '<blockQuote><paragraph>Foo</paragraph></blockQuote>' );
 			} );
+
+			it( 'the same text', () => {
+				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.unwrap();
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients( '<blockQuote>Foo</blockQuote>' );
+			} );
+
+			it( 'the same text, then undo', () => {
+				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.unwrap();
+				kate.unwrap();
+
+				syncClients();
+
+				john.undo();
+
+				syncClients();
+
+				expectClients( '<blockQuote><paragraph>Foo</paragraph></blockQuote>' );
+			} );
 		} );
 
 		describe( 'by delete', () => {
-			it( 'text from two elements', () => {
+			it( 'text from two elements #1', () => {
 				john.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote><paragraph>Bar</paragraph>' );
 				kate.setData( '<blockQuote><paragraph>Fo[o</paragraph></blockQuote><paragraph>Ba]r</paragraph>' );
 

+ 42 - 0
packages/ckeditor5-engine/tests/model/operation/transform/wrap.js

@@ -31,6 +31,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>[Foo]</paragraph><paragraph>Bar</paragraph>' );
+				kate.setData( '<paragraph>Foo</paragraph><paragraph>[Bar]</paragraph>' );
+
+				john.wrap( 'div' );
+				kate.wrap( 'div2' );
+
+				syncClients();
+
+				expectClients(
+					'<paragraph><div>Foo</div></paragraph>' +
+					'<paragraph><div2>Bar</div2></paragraph>'
+				);
+			} );
+
 			it( 'the same element', () => {
 				john.setData( '[<paragraph>Foo</paragraph>]' );
 				kate.setData( '[<paragraph>Foo</paragraph>]' );
@@ -142,6 +157,21 @@ describe( 'transform', () => {
 				);
 			} );
 
+			it( 'text in different path', () => {
+				john.setData( '<paragraph>[Foo]</paragraph><blockQuote><paragraph>Bar</paragraph></blockQuote>' );
+				kate.setData( '<paragraph>Foo</paragraph><blockQuote><paragraph>[Bar]</paragraph></blockQuote>' );
+
+				john.wrap( 'div' );
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients(
+					'<paragraph><div>Foo</div></paragraph>' +
+					'<blockQuote>Bar</blockQuote>'
+				);
+			} );
+
 			it( 'the same element', () => {
 				john.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
 				kate.setData( '<blockQuote>[<paragraph>Foo</paragraph>]</blockQuote>' );
@@ -169,6 +199,18 @@ describe( 'transform', () => {
 
 				expectClients( '<blockQuote><paragraph>Foo</paragraph></blockQuote>' );
 			} );
+
+			it( 'the same text', () => {
+				john.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+				kate.setData( '<blockQuote><paragraph>[Foo]</paragraph></blockQuote>' );
+
+				john.wrap( 'div' );
+				kate.unwrap();
+
+				syncClients();
+
+				expectClients( '<blockQuote><div>Foo</div></blockQuote>' );
+			} );
 		} );
 
 		describe( 'by delete', () => {