8
0
Quellcode durchsuchen

Added missing tests.

Piotrek Koszuliński vor 6 Jahren
Ursprung
Commit
00ec88bf21
1 geänderte Dateien mit 34 neuen und 11 gelöschten Zeilen
  1. 34 11
      packages/ckeditor5-engine/tests/view/domconverter/domconverter.js

+ 34 - 11
packages/ckeditor5-engine/tests/view/domconverter/domconverter.js

@@ -297,37 +297,60 @@ describe( 'DomConverter', () => {
 				converter = new DomConverter( { blockFillerMode: 'nbsp' } );
 			} );
 
-			it( 'should return true if the node is an instance of the NBSP block filler', () => {
-				converter = new DomConverter( { blockFillerMode: 'nbsp' } );
+			it( 'should return true if the node is an nbsp filler and is a single child of a block level element', () => {
 				const nbspFillerInstance = NBSP_FILLER( document ); // eslint-disable-line new-cap
-				// NBSP must be check inside a context.
+
 				const context = document.createElement( 'div' );
 				context.appendChild( nbspFillerInstance );
 
 				expect( converter.isBlockFiller( nbspFillerInstance ) ).to.be.true;
 			} );
 
-			it( 'should return false if the node is an instance of the BR block filler', () => {
-				const brFillerInstance = BR_FILLER( document ); // eslint-disable-line new-cap
+			it( 'should return false if the node is an nbsp filler and is not a single child of a block level element', () => {
+				const nbspFillerInstance = NBSP_FILLER( document ); // eslint-disable-line new-cap
 
-				expect( converter.isBlockFiller( brFillerInstance ) ).to.be.false;
+				const context = document.createElement( 'div' );
+				context.appendChild( nbspFillerInstance );
+				context.appendChild( document.createTextNode( 'a' ) );
+
+				expect( converter.isBlockFiller( nbspFillerInstance ) ).to.be.false;
 			} );
 
-			it( 'should return false if the nbsp filler is inside context', () => {
-				converter = new DomConverter( { blockFillerMode: 'nbsp' } );
+			it( 'should return false if there are two nbsp fillers in a block element', () => {
 				const nbspFillerInstance = NBSP_FILLER( document ); // eslint-disable-line new-cap
-				// NBSP must be check inside a context.
+
 				const context = document.createElement( 'div' );
 				context.appendChild( nbspFillerInstance );
-				// eslint-disable-next-line new-cap
-				context.appendChild( NBSP_FILLER( document ) );
+				context.appendChild( NBSP_FILLER( document ) ); // eslint-disable-line new-cap
 
 				expect( converter.isBlockFiller( nbspFillerInstance ) ).to.be.false;
 			} );
 
+			it( 'should return false filler is placed in a non-block element', () => {
+				const nbspFillerInstance = NBSP_FILLER( document ); // eslint-disable-line new-cap
+
+				const context = document.createElement( 'span' );
+				context.appendChild( nbspFillerInstance );
+
+				expect( converter.isBlockFiller( nbspFillerInstance ) ).to.be.false;
+			} );
+
+			it( 'should return false if the node is an instance of the BR block filler', () => {
+				const brFillerInstance = BR_FILLER( document ); // eslint-disable-line new-cap
+
+				expect( converter.isBlockFiller( brFillerInstance ) ).to.be.false;
+			} );
+
 			it( 'should return false for inline filler', () => {
 				expect( converter.isBlockFiller( document.createTextNode( INLINE_FILLER ) ) ).to.be.false;
 			} );
+
+			it( 'should return false for a normal <br> element', () => {
+				const context = document.createElement( 'div' );
+				context.innerHTML = 'x<br>x';
+
+				expect( converter.isBlockFiller( context.firstChild ) ).to.be.false;
+			} );
 		} );
 
 		describe( 'mode "br"', () => {