Ver código fonte

Added tests checking schema configuration.

Szymon Kupś 9 anos atrás
pai
commit
212c4269bb

+ 2 - 2
packages/ckeditor5-paragraph/src/paragraph.js

@@ -6,8 +6,8 @@
 'use strict';
 
 import Feature from '../feature.js';
-import BuildModelConverterFor from '../engine/treecontroller/model-converter-builder.js';
-import BuildViewConverterFor from '../engine/treecontroller/view-converter-builder.js';
+import BuildModelConverterFor from '../engine/conversion/model-converter-builder.js';
+import BuildViewConverterFor from '../engine/conversion/view-converter-builder.js';
 
 export default class Paragraph extends Feature {
 	init() {

+ 7 - 3
packages/ckeditor5-paragraph/tests/paragraph.js

@@ -21,6 +21,7 @@ describe( 'Paragraph feature', () => {
 
 		return editor.init().then( () => {
 			document = editor.document;
+			document.createRoot( 'main' );
 		} );
 	} );
 
@@ -28,8 +29,13 @@ describe( 'Paragraph feature', () => {
 		expect( editor.plugins.get( Paragraph ) ).to.be.instanceOf( Paragraph );
 	} );
 
+	it( 'should set proper schema rules', () => {
+		expect( document.schema.hasItem( 'paragraph' ) ).to.be.true;
+		expect( document.schema.check( { name: 'paragraph', inside: '$root' } ) ).to.be.true;
+		expect( document.schema.check( { name: '$inline', inside: 'paragraph' } ) ).to.be.true;
+	} );
+
 	it( 'should convert paragraph', () => {
-		document.createRoot( 'main' );
 		editor.setData( '<p>foobar</p>' );
 
 		expect( getData( document, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
@@ -37,7 +43,6 @@ describe( 'Paragraph feature', () => {
 	} );
 
 	it( 'should convert paragraph only', () => {
-		document.createRoot( 'main' );
 		editor.setData( '<p>foo<b>baz</b>bar</p>' );
 
 		expect( getData( document, { withoutSelection: true } ) ).to.equal( '<paragraph>foobazbar</paragraph>' );
@@ -45,7 +50,6 @@ describe( 'Paragraph feature', () => {
 	} );
 
 	it( 'should convert multiple paragraphs', () => {
-		document.createRoot( 'main' );
 		editor.setData( '<p>foo</p><p>baz</p>' );
 
 		expect( getData( document, { withoutSelection: true } ) ).to.equal( '<paragraph>foo</paragraph><paragraph>baz</paragraph>' );