Sfoglia il codice sorgente

Remove return value, correct tests.

Mateusz Samsel 6 anni fa
parent
commit
0204fc93a9

+ 1 - 4
packages/ckeditor5-engine/src/view/upcastwriter.js

@@ -174,6 +174,7 @@ export default class UpcastWriter {
 
 	/**
 	 * Removes given element from view structure and places its children in its position.
+	 * It does nothing if element has no parent.
 	 *
 	 * @param {module:engine/view/element~Element} element Element which will be unwrapped
 	 * @returns {Booolean} Whether element was successfully unwrapped.
@@ -186,11 +187,7 @@ export default class UpcastWriter {
 
 			this.remove( element );
 			this.insertChild( index, element.getChildren(), parent );
-
-			return true;
 		}
-
-		return false;
 	}
 
 	/**

+ 8 - 8
packages/ckeditor5-engine/tests/view/upcastwriter.js

@@ -329,12 +329,12 @@ describe( 'UpcastWriter', () => {
 	} );
 
 	describe( 'unwrapElement', () => {
-		it( 'should unwrap simple elements', () => {
+		it( 'should unwrap simple element', () => {
 			const documentFragment = dataprocessor.toView( '<ul><li><p>foo</p></li></ul>' );
 			const paragraph = documentFragment.getChild( 0 ).getChild( 0 ).getChild( 0 );
-			const unwrapStatus = writer.unwrapElement( paragraph );
 
-			expect( unwrapStatus ).to.be.true;
+			writer.unwrapElement( paragraph );
+
 			expect( dataprocessor.toData( documentFragment ) ).to.equal( '<ul><li>foo</li></ul>' );
 		} );
 
@@ -342,18 +342,18 @@ describe( 'UpcastWriter', () => {
 			const documentFragment = dataprocessor.toView(
 				'<p><span style="color:red"><strong>foo</strong><a href="example.com">example</a>bar</span></p>' );
 			const span = documentFragment.getChild( 0 ).getChild( 0 );
-			const unwrapStatus = writer.unwrapElement( span );
 
-			expect( unwrapStatus ).to.be.true;
+			writer.unwrapElement( span );
+
 			expect( dataprocessor.toData( documentFragment ) ).to.equal(
 				'<p><strong>foo</strong><a href="example.com">example</a>bar</p>' );
 		} );
 
-		it( 'should not be applied to elements without parent', () => {
+		it( 'should do nothing for elements without parent', () => {
 			const element = new Element( 'p', null, 'foo' );
-			const unwrapStatus = writer.unwrapElement( element );
 
-			expect( unwrapStatus ).to.be.false;
+			writer.unwrapElement( element );
+
 			expect( dataprocessor.toData( element ) ).to.equal( '<p>foo</p>' );
 		} );
 	} );