Преглед на файлове

Tests: some tests to get 100% CC on buildViewConverter.

Szymon Cofalik преди 9 години
родител
ревизия
812c1a0674
променени са 1 файла, в които са добавени 22 реда и са изтрити 7 реда
  1. 22 7
      packages/ckeditor5-engine/tests/conversion/buildviewconverter.js

+ 22 - 7
packages/ckeditor5-engine/tests/conversion/buildviewconverter.js

@@ -341,21 +341,36 @@ describe( 'View converter builder', () => {
 		expect( modelToString( result ) ).to.equal( '<div class="myClass"><abcd>foo</abcd></div>' );
 	} );
 
-	it( 'should filter out structure that is wrong with schema', () => {
-		buildViewConverter().for( dispatcher ).fromElement( 'strong' ).toAttribute( 'bold', true );
+	it( 'should filter out structure that is wrong with schema - elements', () => {
 		buildViewConverter().for( dispatcher ).fromElement( 'div' ).toElement( 'div' );
 		buildViewConverter().for( dispatcher ).fromElement( 'p' ).toElement( 'paragraph' );
 
-		schema.disallow( { name: '$text', attributes: 'bold', inside: 'paragraph' } );
 		schema.disallow( { name: 'div', inside: '$root' } );
 
-		dispatcher.on( 'element', convertToModelFragment() );
+		dispatcher.on( 'element', convertToModelFragment(), { priority: 'lowest' } );
 
 		let viewElement = new ViewContainerElement( 'div', null,
 			new ViewContainerElement( 'p', null,
-				new ViewAttributeElement( 'strong', null,
-					new ViewText( 'foo' )
-				)
+				new ViewText( 'foo' )
+			)
+		);
+
+		let result = dispatcher.convert( viewElement, objWithContext );
+
+		expect( modelToString( result ) ).to.equal( '<paragraph>foo</paragraph>' );
+	} );
+
+	it( 'should filter out structure that is wrong with schema - attributes', () => {
+		buildViewConverter().for( dispatcher ).fromElement( 'p' ).toElement( 'paragraph' );
+		buildViewConverter().for( dispatcher ).fromElement( 'strong' ).toAttribute( 'bold', true );
+
+		schema.disallow( { name: '$text', attributes: 'bold', inside: 'paragraph' } );
+
+		dispatcher.on( 'element', convertToModelFragment(), { priority: 'lowest' } );
+
+		let viewElement = new ViewContainerElement( 'p', null,
+			new ViewAttributeElement( 'strong', null,
+				new ViewText( 'foo' )
 			)
 		);