浏览代码

Tests: fixed schema configurations.

Piotrek Koszuliński 9 年之前
父节点
当前提交
4a89a4d6eb

+ 2 - 2
packages/ckeditor5-engine/src/dev-utils/model.js

@@ -354,7 +354,7 @@ function convertToModelElement() {
 		};
 
 		if ( !conversionApi.schema.check( schemaQuery ) ) {
-			throw new Error( `Element '${ schemaQuery.name }' not allowed in context.` );
+			throw new Error( `Element '${ schemaQuery.name }' not allowed in context ${ JSON.stringify( data.context ) }.` );
 		}
 
 		// View attribute value is a string so we want to typecast it to the original type.
@@ -380,7 +380,7 @@ function convertToModelText( withAttributes = false ) {
 		};
 
 		if ( !conversionApi.schema.check( schemaQuery ) ) {
-			throw new Error( `Element '${ schemaQuery.name }' not allowed in context.` );
+			throw new Error( `Element '${ schemaQuery.name }' not allowed in context ${ JSON.stringify( data.context ) }.` );
 		}
 
 		let node;

+ 8 - 2
packages/ckeditor5-engine/tests/controller/datacontroller.js

@@ -339,7 +339,10 @@ describe( 'DataController', () => {
 	describe( 'stringify', () => {
 		beforeEach( () => {
 			modelDocument.schema.registerItem( 'paragraph', '$block' );
-			modelDocument.schema.registerItem( 'div', '$block' );
+			modelDocument.schema.registerItem( 'div' );
+
+			modelDocument.schema.allow( { name: '$block', inside: 'div' } );
+			modelDocument.schema.allow( { name: 'div', inside: '$root' } );
 
 			buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
 		} );
@@ -360,7 +363,10 @@ describe( 'DataController', () => {
 	describe( 'toView', () => {
 		beforeEach( () => {
 			modelDocument.schema.registerItem( 'paragraph', '$block' );
-			modelDocument.schema.registerItem( 'div', '$block' );
+			modelDocument.schema.registerItem( 'div' );
+
+			modelDocument.schema.allow( { name: '$block', inside: 'div' } );
+			modelDocument.schema.allow( { name: 'div', inside: '$root' } );
 
 			buildModelConverter().for( data.modelToView ).fromElement( 'paragraph' ).toElement( 'p' );
 		} );

+ 1 - 0
packages/ckeditor5-engine/tests/controller/deletecontent.js

@@ -157,6 +157,7 @@ describe( 'DataController', () => {
 				schema.registerItem( 'image', '$inline' );
 
 				schema.allow( { name: 'pchild', inside: 'paragraph' } );
+				schema.allow( { name: '$text', inside: 'pchild' } );
 				schema.allow( { name: 'paragraph', attributes: [ 'align' ] } );
 			} );
 

+ 2 - 0
packages/ckeditor5-engine/tests/controller/insertcontent.js

@@ -48,6 +48,7 @@ describe( 'DataController', () => {
 				schema.allow( { name: 'image', inside: '$root' } );
 				// Otherwise it won't be passed to the temporary model fragment used inside insert().
 				schema.allow( { name: 'disallowedElement', inside: '$clipboardHolder' } );
+				doc.schema.allow( { name: '$text', inside: 'disallowedElement' } );
 
 				schema.allow( { name: '$inline', attributes: [ 'bold' ] } );
 				schema.allow( { name: '$inline', attributes: [ 'italic' ] } );
@@ -513,6 +514,7 @@ describe( 'DataController', () => {
 
 				schema.allow( { name: 'table', inside: '$clipboardHolder' } );
 				schema.allow( { name: 'td', inside: '$clipboardHolder' } );
+				schema.allow( { name: 'td', inside: 'table' } );
 				schema.allow( { name: '$block', inside: 'td' } );
 				schema.allow( { name: '$text', inside: 'td' } );
 

+ 6 - 0
packages/ckeditor5-engine/tests/controller/modifyselection.js

@@ -18,7 +18,13 @@ describe( 'DataController', () => {
 		document.schema.registerItem( 'p', '$block' );
 		document.schema.registerItem( 'x', '$block' );
 		document.schema.registerItem( 'img', '$inline' );
+
 		document.schema.allow( { name: '$text', inside: '$root' } );
+		document.schema.allow( { name: '$text', inside: 'img' } );
+		document.schema.allow( { name: '$text', inside: 'obj' } );
+		document.schema.allow( { name: '$text', inside: 'inlineObj' } );
+		document.schema.allow( { name: 'x', inside: 'p' } );
+
 		document.createRoot();
 	} );