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

Added tests for cleaning up empty block quotes.

Piotrek Koszuliński 8 лет назад
Родитель
Сommit
b0120f1118

+ 36 - 0
packages/ckeditor5-block-quote/tests/integration.js

@@ -252,5 +252,41 @@ describe( 'BlockQuote', () => {
 				'<paragraph>y</paragraph>'
 				'<paragraph>y</paragraph>'
 			);
 			);
 		} );
 		} );
+
+		it( 'removes empty quote when merging into another quote', () => {
+			const data = fakeEventData();
+
+			setModelData( doc,
+				'<paragraph>x</paragraph>' +
+				'<blockQuote><paragraph>a</paragraph></blockQuote>' +
+				'<blockQuote><paragraph>[]</paragraph></blockQuote>' +
+				'<paragraph>y</paragraph>'
+			);
+
+			editor.editing.view.fire( 'delete', data );
+
+			expect( getModelData( doc ) ).to.equal(
+				'<paragraph>x</paragraph>' +
+				'<blockQuote><paragraph>a[]</paragraph></blockQuote>' +
+				'<paragraph>y</paragraph>'
+			);
+		} );
+
+		it( 'removes empty quote when merging into a paragraph', () => {
+			const data = fakeEventData();
+
+			setModelData( doc,
+				'<paragraph>x</paragraph>' +
+				'<blockQuote><paragraph>[]</paragraph></blockQuote>' +
+				'<paragraph>y</paragraph>'
+			);
+
+			editor.editing.view.fire( 'delete', data );
+
+			expect( getModelData( doc ) ).to.equal(
+				'<paragraph>x[]</paragraph>' +
+				'<paragraph>y</paragraph>'
+			);
+		} );
 	} );
 	} );
 } );
 } );

+ 6 - 0
packages/ckeditor5-block-quote/tests/manual/blockquote.js

@@ -9,6 +9,8 @@ import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classic';
 import ArticlePreset from '@ckeditor/ckeditor5-presets/src/article';
 import ArticlePreset from '@ckeditor/ckeditor5-presets/src/article';
 import BlockQuote from '../../src/blockquote';
 import BlockQuote from '../../src/blockquote';
 
 
+import { getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
+
 ClassicEditor.create( document.querySelector( '#editor' ), {
 ClassicEditor.create( document.querySelector( '#editor' ), {
 	plugins: [
 	plugins: [
 		ArticlePreset,
 		ArticlePreset,
@@ -22,3 +24,7 @@ ClassicEditor.create( document.querySelector( '#editor' ), {
 .catch( err => {
 .catch( err => {
 	console.error( err.stack );
 	console.error( err.stack );
 } );
 } );
+
+window.setInterval( function() {
+	console.log( getData( window.editor.document ) );
+}, 3000 );