Browse Source

Added an integration test which checks whether blockQuote will not be merging with the list item.

Kamil Piechaczek 7 years ago
parent
commit
63d1da2705

+ 1 - 0
packages/ckeditor5-block-quote/package.json

@@ -16,6 +16,7 @@
     "@ckeditor/ckeditor5-editor-classic": "^1.0.0-alpha.2",
     "@ckeditor/ckeditor5-enter": "^1.0.0-alpha.2",
     "@ckeditor/ckeditor5-essentials": "^1.0.0-alpha.2",
+    "@ckeditor/ckeditor5-heading": "^1.0.0-alpha.2",
     "@ckeditor/ckeditor5-image": "^1.0.0-alpha.2",
     "@ckeditor/ckeditor5-list": "^1.0.0-alpha.2",
     "@ckeditor/ckeditor5-paragraph": "^1.0.0-alpha.2",

+ 26 - 2
packages/ckeditor5-block-quote/tests/integration.js

@@ -12,9 +12,10 @@ import ImageCaption from '@ckeditor/ckeditor5-image/src/imagecaption';
 import List from '@ckeditor/ckeditor5-list/src/list';
 import Enter from '@ckeditor/ckeditor5-enter/src/enter';
 import Delete from '@ckeditor/ckeditor5-typing/src/delete';
+import Heading from '@ckeditor/ckeditor5-heading/src/heading';
 
 import ClassicTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/classictesteditor';
-import { getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+import { parse, getData as getModelData, setData as setModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 describe( 'BlockQuote integration', () => {
 	let editor, model, element;
@@ -25,7 +26,7 @@ describe( 'BlockQuote integration', () => {
 
 		return ClassicTestEditor
 			.create( element, {
-				plugins: [ BlockQuote, Paragraph, Image, ImageCaption, List, Enter, Delete ]
+				plugins: [ BlockQuote, Paragraph, Image, ImageCaption, List, Enter, Delete, Heading ]
 			} )
 			.then( newEditor => {
 				editor = newEditor;
@@ -388,4 +389,27 @@ describe( 'BlockQuote integration', () => {
 			);
 		} );
 	} );
+
+	// When blockQuote with a paragraph was pasted into a list item, the item contained the paragraph. It was invalid.
+	// There is a test which checks whether blockQuote will split the list items instead of merging with.
+	describe( 'compatibility with lists', () => {
+		it( 'does not merge the paragraph with list item', () => {
+			setModelData( model, '<listItem indent="0" type="bulleted">fo[]o</listItem>' );
+
+			const df = parse(
+				'<blockQuote><paragraph>xxx</paragraph></blockQuote><heading1>yyy</heading1>',
+				model.schema
+			);
+
+			model.insertContent( df, model.document.selection );
+
+			expect( getModelData( model ) ).to.equal(
+				'<listItem indent="0" type="bulleted">fo</listItem>' +
+				'<blockQuote>' +
+				'<paragraph>xxx</paragraph>' +
+				'</blockQuote>' +
+				'<heading1>yyy[]o</heading1>'
+			);
+		} );
+	} );
 } );