浏览代码

Added clone tests to EditableElement and RootEditableElement.

Szymon Kupś 9 年之前
父节点
当前提交
8a81a7b883

+ 2 - 12
packages/ckeditor5-engine/src/view/rooteditableelement.js

@@ -30,28 +30,18 @@ export default class RootEditableElement extends EditableElement {
 		super( name );
 
 		/**
-		 * Name of this root inside {@link module:engine/view/document~Document} that is an owner of this root.
+		 * Name of this root inside {@link module:engine/view/document~Document} that is an owner of this root. If no
+		 * other name is set, `main` name is used.
 		 *
-		 * @readonly
 		 * @member {String}
 		 */
 		this.rootName = 'main';
 	}
 
-	/**
-	 * Gets root name inside parent {@link module:engine/view/document~Document}.
-	 *
-	 * @type {String}
-	 */
 	get rootName() {
 		return this.getCustomProperty( rootNameSymbol );
 	}
 
-	/**
-	 * Sets root name inside parent {@link module:engine/view/document~Document}.
-	 *
-	 * @type {String}
-	 */
 	set rootName( rootName ) {
 		this.setCustomProperty( rootNameSymbol, rootName );
 	}

+ 7 - 0
packages/ckeditor5-engine/tests/view/editableelement.js

@@ -35,6 +35,13 @@ describe( 'EditableElement', () => {
 				element.document = newDoc;
 			} ).to.throw( CKEditorError, 'view-editableelement-document-already-set: View document is already set.' );
 		} );
+
+		it( 'should be cloned properly', () => {
+			element.document = docMock;
+			const newElement = element.clone();
+
+			expect( newElement.document ).to.equal( docMock );
+		} );
 	} );
 
 	describe( 'isFocused', () => {

+ 11 - 0
packages/ckeditor5-engine/tests/view/rooteditableelement.js

@@ -37,4 +37,15 @@ describe( 'RootEditableElement', () => {
 			expect( root.isReadOnly ).to.be.false;
 		} );
 	} );
+
+	it( 'should be cloned properly', () => {
+		const root = new RootEditableElement( 'h1' );
+		root.document = createDocumentMock();
+		root.rootName = 'header';
+
+		const newRoot = root.clone();
+
+		expect( newRoot.document ).to.equal( root.document );
+		expect( newRoot.rootName ).to.equal( root.rootName );
+	} );
 } );