Browse Source

Tests: Added a test to check what happens if an unsplittable parent does not allow codeBlock during upcasting.

Aleksander Nowodzinski 6 years ago
parent
commit
0e4172727b
1 changed files with 13 additions and 0 deletions
  1. 13 0
      packages/ckeditor5-code-block/tests/codeblockediting.js

+ 13 - 0
packages/ckeditor5-code-block/tests/codeblockediting.js

@@ -469,6 +469,19 @@ describe( 'CodeBlockEditing', () => {
 			expect( getModelData( model ) ).to.equal(
 			expect( getModelData( model ) ).to.equal(
 				'<codeBlock language="plaintext">[]foo</codeBlock><codeBlock language="plaintext">bar</codeBlock>' );
 				'<codeBlock language="plaintext">[]foo</codeBlock><codeBlock language="plaintext">bar</codeBlock>' );
 		} );
 		} );
+
+		it( 'should not convert when modelCursor and its ancestors disallow to insert codeBlock', () => {
+			model.document.createRoot( '$title', 'title' );
+
+			model.schema.register( '$title', {
+				disallow: '$block',
+				allow: 'inline'
+			} );
+
+			editor.data.set( { title: '<pre><code>foo</code></pre>' } );
+
+			expect( getModelData( model, { rootName: 'title', withoutSelection: true } ) ).to.equal( '' );
+		} );
 	} );
 	} );
 
 
 	describe( 'clipboard integration', () => {
 	describe( 'clipboard integration', () => {