Ver código fonte

#396: Update documentation and imports for deltas.

Maciej Gołaszewski 9 anos atrás
pai
commit
e2ecc94cb7

+ 61 - 0
packages/ckeditor5-engine/tests/treemodel/element.js

@@ -241,6 +241,67 @@ describe( 'Element', () => {
 		} );
 	} );
 
+	describe( 'toJSON', () => {
+		it( 'should serialize empty node', () => {
+			let element = new Element( 'one' );
+
+			expect( treeModelTestUtils.jsonParseStringify( element ) ).to.deep.equal( {
+				_attrs: [],
+				_children: {
+					_indexMap: [],
+					_nodes: []
+				},
+				name: 'one'
+			} );
+		} );
+
+		it( 'should serialize node with attributes', () => {
+			let node = new Element( 'one', { foo: true, bar: false } );
+
+			expect( treeModelTestUtils.jsonParseStringify( node ) ).to.deep.equal( {
+				_attrs: [ [ 'foo', true ], [ 'bar', false ] ],
+				_children: {
+					_indexMap: [],
+					_nodes: []
+				},
+				name: 'one'
+			} );
+		} );
+
+		it( 'should serialize node with children', () => {
+			let img = new Element( 'img' );
+			let one = new Element( 'one' );
+			let two = new Element( 'two', null, [ 'b', 'a', img, 'r' ] );
+			let three = new Element( 'three' );
+
+			let node = new Element( null, null, [ one, two, three ] );
+
+			expect( treeModelTestUtils.jsonParseStringify( node ) ).to.deep.equal( {
+				_attrs: [],
+				_children: {
+					_indexMap: [ 0, 1, 2 ],
+					_nodes: [
+						{ _attrs: [], _children: { _indexMap: [], _nodes: [] }, name: 'one' },
+						{
+							_attrs: [],
+							_children: {
+								_indexMap: [ 0, 0, 1, 2 ],
+								_nodes: [
+									{ _attrs: [], text: 'ba' },
+									{ _attrs: [], _children: { _indexMap: [], _nodes: [] }, name: 'img' },
+									{ _attrs: [], text: 'r' }
+								]
+							},
+							name: 'two'
+						},
+						{ _attrs: [], _children: { _indexMap: [], _nodes: [] }, name: 'three' }
+					]
+				},
+				name: null
+			} );
+		} );
+	} );
+
 	describe( 'fromJSON', () => {
 		it( 'should create element without attributes', () => {
 			const el = new Element( 'el' );

+ 0 - 55
packages/ckeditor5-engine/tests/treemodel/node.js

@@ -9,7 +9,6 @@
 
 import Element from '/ckeditor5/engine/treemodel/element.js';
 import CKEditorError from '/ckeditor5/utils/ckeditorerror.js';
-import treeModelTestUtils from '/tests/engine/treemodel/_utils/utils.js';
 
 describe( 'Node', () => {
 	let root;
@@ -170,58 +169,4 @@ describe( 'Node', () => {
 			} );
 		} );
 	} );
-
-	describe( 'toJSON', () => {
-		it( 'should serialize empty node', () => {
-			let node = new Element( 'one' );
-
-			expect( treeModelTestUtils.jsonParseStringify( node ) ).to.deep.equal( {
-				_attrs: [],
-				_children: {
-					_indexMap: [],
-					_nodes: []
-				},
-				name: 'one'
-			} );
-		} );
-
-		it( 'should serialize node with attributes', () => {
-			let node = new Element( 'one', { foo: true, bar: false } );
-
-			expect( treeModelTestUtils.jsonParseStringify( node ) ).to.deep.equal( {
-				_attrs: [ [ 'foo', true ], [ 'bar', false ] ],
-				_children: {
-					_indexMap: [],
-					_nodes: []
-				},
-				name: 'one'
-			} );
-		} );
-
-		it( 'should serialize node with children', () => {
-			expect( treeModelTestUtils.jsonParseStringify( root ) ).to.deep.equal( {
-				_attrs: [],
-				_children: {
-					_indexMap: [ 0, 1, 2 ],
-					_nodes: [
-						{ _attrs: [], _children: { _indexMap: [], _nodes: [] }, name: 'one' },
-						{
-							_attrs: [],
-							_children: {
-								_indexMap: [ 0, 0, 1, 2 ],
-								_nodes: [
-									{ _attrs: [], text: 'ba' },
-									{ _attrs: [], _children: { _indexMap: [], _nodes: [] }, name: 'img' },
-									{ _attrs: [], text: 'r' }
-								]
-							},
-							name: 'two'
-						},
-						{ _attrs: [], _children: { _indexMap: [], _nodes: [] }, name: 'three' }
-					]
-				},
-				name: null
-			} );
-		} );
-	} );
 } );