Ver código fonte

Tests: fixed schema configurations.

Piotrek Koszuliński 9 anos atrás
pai
commit
b4b502d4b6

+ 1 - 0
packages/ckeditor5-engine/tests/conversion/buildviewconverter.js

@@ -80,6 +80,7 @@ describe( 'View converter builder', () => {
 		schema.allow( { name: '$inline', attributes: textAttributes, inside: '$root' } );
 		schema.allow( { name: 'image', attributes: [ 'src' ], inside: '$root' } );
 		schema.allow( { name: 'image', attributes: [ 'src' ], inside: '$block' } );
+		schema.allow( { name: '$text', inside: '$inline' } );
 		schema.allow( { name: '$text', attributes: textAttributes, inside: '$block' } );
 		schema.allow( { name: '$text', attributes: textAttributes, inside: '$root' } );
 		schema.allow( { name: 'paragraph', attributes: pAttributes, inside: '$root' } );

+ 8 - 3
packages/ckeditor5-engine/tests/conversion/model-selection-to-view-converters.js

@@ -426,9 +426,14 @@ describe( 'model-selection-to-view-converters', () => {
 
 	describe( 'table cell selection converter', () => {
 		beforeEach( () => {
-			modelDoc.schema.registerItem( 'table', '$block' );
-			modelDoc.schema.registerItem( 'tr', '$block' );
-			modelDoc.schema.registerItem( 'td', '$block' );
+			modelDoc.schema.registerItem( 'table' );
+			modelDoc.schema.registerItem( 'tr' );
+			modelDoc.schema.registerItem( 'td' );
+
+			modelDoc.schema.allow( { name: 'table', inside: '$root' } );
+			modelDoc.schema.allow( { name: 'tr', inside: 'table' } );
+			modelDoc.schema.allow( { name: 'td', inside: 'tr' } );
+			modelDoc.schema.allow( { name: '$text', inside: 'td' } );
 
 			// "Universal" converter to convert table structure.
 			const tableConverter = insertElement( ( data ) => new ViewContainerElement( data.item.name ) );

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

@@ -25,13 +25,19 @@ describe( 'model test utils', () => {
 		document.schema.registerItem( 'a', '$inline' );
 		document.schema.allow( { name: 'a', inside: '$root' } );
 		document.schema.allow( { name: 'a', inside: '$root', attributes: [ 'bar', 'car', 'foo' ] } );
+
 		document.schema.registerItem( 'b', '$inline' );
 		document.schema.allow( { name: 'b', inside: '$root' } );
 		document.schema.allow( { name: 'b', inside: '$root', attributes: [ 'barFoo', 'fooBar', 'x' ] } );
+
 		document.schema.registerItem( 'c', '$inline' );
 		document.schema.allow( { name: 'c', inside: '$root' } );
+
 		document.schema.registerItem( 'paragraph', '$block' );
 		document.schema.allow( { name: '$text', inside: '$root' } );
+		document.schema.allow( { name: '$text', inside: 'a' } );
+		document.schema.allow( { name: '$text', inside: 'b' } );
+		document.schema.allow( { name: 'c', inside: 'b' } );
 	} );
 
 	afterEach( () => {
@@ -480,7 +486,7 @@ describe( 'model test utils', () => {
 		it( 'throws when try to set element not registered in schema', () => {
 			expect( () => {
 				parse( '<xyz></xyz>', document.schema );
-			} ).to.throw( Error, `Element 'xyz' not allowed in context.` );
+			} ).to.throw( Error, `Element 'xyz' not allowed in context ["$root"].` );
 		} );
 
 		it( 'throws when try to set text directly to $root without registering it', () => {
@@ -488,7 +494,7 @@ describe( 'model test utils', () => {
 
 			expect( () => {
 				parse( 'text', doc.schema );
-			} ).to.throw( Error, `Element '$text' not allowed in context.` );
+			} ).to.throw( Error, `Element '$text' not allowed in context ["$root"].` );
 		} );
 
 		it( 'converts data in the specified context', () => {