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

Code style corrections for tests.

Szymon Cofalik преди 10 години
родител
ревизия
b4d0ca1716

+ 84 - 53
packages/ckeditor5-utils/tests/document/changeoperation.js

@@ -16,7 +16,8 @@ var modules = bender.amd.require(
 	'document/attribute',
 	'document/nodelist',
 	'document/text',
-	'ckeditorerror' );
+	'ckeditorerror'
+);
 
 describe( 'ChangeOperation', function() {
 	var Document, ChangeOperation, Position, Range, Character, Attribute, NodeList, Text, CKEditorError;
@@ -45,11 +46,14 @@ describe( 'ChangeOperation', function() {
 
 		root.insertChildren( 0, 'bar' );
 
-		doc.applyOperation( new ChangeOperation(
-			new Range( new Position( [ 0 ], root ), new Position( [ 2 ], root ) ),
-			null,
-			newAttr,
-			doc.version ) );
+		doc.applyOperation(
+			new ChangeOperation(
+				new Range( new Position( [ 0 ], root ), new Position( [ 2 ], root ) ),
+				null,
+				newAttr,
+				doc.version
+			)
+		);
 
 		expect( doc.version ).to.equal( 1 );
 		expect( root.getChildCount() ).to.equal( 3 );
@@ -65,11 +69,14 @@ describe( 'ChangeOperation', function() {
 
 		root.insertChildren( 0, new Character( 'x', [ fooAttr, barAttr ] ) );
 
-		doc.applyOperation( new ChangeOperation(
-			new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-			null,
-			newAttr,
-			doc.version ) );
+		doc.applyOperation(
+			new ChangeOperation(
+				new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
+				null,
+				newAttr,
+				doc.version
+			)
+		);
 
 		expect( doc.version ).to.equal( 1 );
 		expect( root.getChildCount() ).to.equal( 1 );
@@ -85,11 +92,14 @@ describe( 'ChangeOperation', function() {
 
 		root.insertChildren( 0, new Text( 'bar', [ oldAttr ] ) );
 
-		doc.applyOperation( new ChangeOperation(
-			new Range( new Position( [ 0 ], root ), new Position( [ 2 ], root ) ),
-			oldAttr,
-			newAttr,
-			doc.version ) );
+		doc.applyOperation(
+			new ChangeOperation(
+				new Range( new Position( [ 0 ], root ), new Position( [ 2 ], root ) ),
+				oldAttr,
+				newAttr,
+				doc.version
+			)
+		);
 
 		expect( doc.version ).to.equal( 1 );
 		expect( root.getChildCount() ).to.equal( 3 );
@@ -109,11 +119,14 @@ describe( 'ChangeOperation', function() {
 
 		root.insertChildren( 0, new Character( 'x', [ fooAttr, x1Attr, barAttr ] ) );
 
-		doc.applyOperation( new ChangeOperation(
-			new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-			x1Attr,
-			x2Attr,
-			doc.version ) );
+		doc.applyOperation(
+			new ChangeOperation(
+				new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
+				x1Attr,
+				x2Attr,
+				doc.version
+			)
+		);
 
 		expect( doc.version ).to.equal( 1 );
 		expect( root.getChildCount() ).to.equal( 1 );
@@ -130,11 +143,14 @@ describe( 'ChangeOperation', function() {
 
 		root.insertChildren( 0, new Character( 'x', [ fooAttr, xAttr, barAttr ] ) );
 
-		doc.applyOperation( new ChangeOperation(
-			new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-			xAttr,
-			null,
-			doc.version ) );
+		doc.applyOperation(
+			new ChangeOperation(
+				new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
+				xAttr,
+				null,
+				doc.version
+			)
+		);
 
 		expect( doc.version ).to.equal( 1 );
 		expect( root.getChildCount() ).to.equal( 1 );
@@ -146,11 +162,8 @@ describe( 'ChangeOperation', function() {
 	it( 'should create a change operation as a reverse', function() {
 		var oldAttr = new Attribute( 'x', 'old' );
 		var newAttr = new Attribute( 'x', 'new' );
-
 		var range = new Range( new Position( [ 0 ], root ), new Position( [ 3 ], root ) );
-
 		var operation = new ChangeOperation( range, oldAttr, newAttr, doc.version );
-
 		var reverse = operation.reverseOperation();
 
 		expect( reverse ).to.be.an.instanceof( ChangeOperation );
@@ -169,7 +182,8 @@ describe( 'ChangeOperation', function() {
 			new Range( new Position( [ 0 ], root ), new Position( [ 3 ], root ) ),
 			null,
 			newAttr,
-			doc.version );
+			doc.version
+		);
 
 		var reverse = operation.reverseOperation();
 
@@ -193,7 +207,8 @@ describe( 'ChangeOperation', function() {
 			new Range( new Position( [ 0 ], root ), new Position( [ 3 ], root ) ),
 			oldAttr,
 			newAttr,
-			doc.version );
+			doc.version
+		);
 
 		var reverse = operation.reverseOperation();
 
@@ -220,7 +235,8 @@ describe( 'ChangeOperation', function() {
 			new Range( new Position( [ 0 ], root ), new Position( [ 3 ], root ) ),
 			fooAttr,
 			null,
-			doc.version );
+			doc.version
+		);
 
 		var reverse = operation.reverseOperation();
 
@@ -243,13 +259,18 @@ describe( 'ChangeOperation', function() {
 
 		root.insertChildren( 0, 'x' );
 
-		expect( function() {
-			doc.applyOperation( new ChangeOperation(
-				new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-				fooAttr,
-				null,
-				doc.version ) );
-		} ).to.throw( CKEditorError, /operation-change-no-attr-to-remove/ );
+		expect(
+			function() {
+				doc.applyOperation(
+					new ChangeOperation(
+						new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
+						fooAttr,
+						null,
+						doc.version
+					)
+				);
+			}
+		).to.throw( CKEditorError, /operation-change-no-attr-to-remove/ );
 	} );
 
 	it( 'should throw an error when one try to insert and the attribute already exists', function() {
@@ -258,13 +279,18 @@ describe( 'ChangeOperation', function() {
 
 		root.insertChildren( 0, new Character( 'x', [ x1Attr ] ) );
 
-		expect( function() {
-			doc.applyOperation( new ChangeOperation(
-				new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-				null,
-				x2Attr,
-				doc.version ) );
-		} ).to.throw( CKEditorError, /operation-change-attr-exists/ );
+		expect(
+			function() {
+				doc.applyOperation(
+					new ChangeOperation(
+						new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
+						null,
+						x2Attr,
+						doc.version
+					)
+				);
+			}
+		).to.throw( CKEditorError, /operation-change-attr-exists/ );
 	} );
 
 	it( 'should throw an error when one try to change and the new and old attributes have different keys', function() {
@@ -273,12 +299,17 @@ describe( 'ChangeOperation', function() {
 
 		root.insertChildren( 0, 'x' );
 
-		expect( function() {
-			doc.applyOperation( new ChangeOperation(
-				new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
-				fooAttr,
-				barAttr,
-				doc.version ) );
-		} ).to.throw( CKEditorError, /operation-change-different-keys/ );
+		expect(
+			function() {
+				doc.applyOperation(
+					new ChangeOperation(
+						new Range( new Position( [ 0 ], root ), new Position( [ 1 ], root ) ),
+						fooAttr,
+						barAttr,
+						doc.version
+					)
+				);
+			}
+		).to.throw( CKEditorError, /operation-change-different-keys/ );
 	} );
 } );

+ 2 - 1
packages/ckeditor5-utils/tests/document/character.js

@@ -13,7 +13,8 @@ var modules = bender.amd.require(
 	'document/character',
 	'document/node',
 	'document/element',
-	'document/attribute' );
+	'document/attribute'
+);
 
 describe( 'Character', function() {
 	var Element, Character, Node, Attribute;

+ 20 - 10
packages/ckeditor5-utils/tests/document/document.js

@@ -7,7 +7,11 @@
 
 'use strict';
 
-var modules = bender.amd.require( 'document/document', 'document/rootelement', 'ckeditorerror' );
+var modules = bender.amd.require(
+	'document/document',
+	'document/rootelement',
+	'ckeditorerror'
+);
 
 describe( 'Document', function() {
 	var Document, RootElement, CKEditorError;
@@ -45,9 +49,11 @@ describe( 'Document', function() {
 		it( 'should throw an error when trying to create a second root with the same name', function() {
 			document.createRoot( 'root' );
 
-			expect( function() {
-				document.createRoot( 'root' );
-			} ).to.throw( CKEditorError, /document-createRoot-name-exists/ );
+			expect(
+				function() {
+					document.createRoot( 'root' );
+				}
+			).to.throw( CKEditorError, /document-createRoot-name-exists/ );
 		} );
 	} );
 
@@ -60,9 +66,11 @@ describe( 'Document', function() {
 		} );
 
 		it( 'should throw an error when trying to get non-existent root', function() {
-			expect( function() {
-				document.getRoot( 'root' );
-			} ).to.throw( CKEditorError, /document-createRoot-root-not-exist/ );
+			expect(
+				function() {
+					document.getRoot( 'root' );
+				}
+			).to.throw( CKEditorError, /document-createRoot-root-not-exist/ );
 		} );
 	} );
 
@@ -91,9 +99,11 @@ describe( 'Document', function() {
 
 			document.on( 'operationApplied', operationApplied );
 
-			expect( function() {
-				document.applyOperation( operation );
-			} ).to.throw( CKEditorError, /document-applyOperation-wrong-version/ );
+			expect(
+				function() {
+					document.applyOperation( operation );
+				}
+			).to.throw( CKEditorError, /document-applyOperation-wrong-version/ );
 		} );
 	} );
 } );

+ 2 - 1
packages/ckeditor5-utils/tests/document/element.js

@@ -13,7 +13,8 @@ var modules = bender.amd.require(
 	'document/node',
 	'document/nodelist',
 	'document/element',
-	'document/attribute' );
+	'document/attribute'
+);
 
 describe( 'Element', function() {
 	var Element, Node, NodeList, Attribute;

+ 42 - 14
packages/ckeditor5-utils/tests/document/insertoperation.js

@@ -13,7 +13,8 @@ var modules = bender.amd.require(
 	'document/removeoperation',
 	'document/position',
 	'document/character',
-	'document/nodelist' );
+	'document/nodelist'
+);
 
 describe( 'InsertOperation', function() {
 	var Document, InsertOperation, RemoveOperation, Position, Character;
@@ -34,10 +35,13 @@ describe( 'InsertOperation', function() {
 	} );
 
 	it( 'should insert node', function() {
-		doc.applyOperation( new InsertOperation(
-			new Position( [ 0 ], root ),
-			new Character( 'x' ),
-			doc.version ) );
+		doc.applyOperation(
+			new InsertOperation(
+				new Position( [ 0 ], root ),
+				new Character( 'x' ),
+				doc.version
+			)
+		);
 
 		expect( doc.version ).to.equal( 1 );
 		expect( root.getChildCount() ).to.equal( 1 );
@@ -45,7 +49,13 @@ describe( 'InsertOperation', function() {
 	} );
 
 	it( 'should insert set of nodes', function() {
-		doc.applyOperation( new InsertOperation( new Position( [ 0 ], root ), 'bar', doc.version ) );
+		doc.applyOperation(
+			new InsertOperation(
+				new Position( [ 0 ], root ),
+				'bar',
+				doc.version
+			)
+		);
 
 		expect( doc.version ).to.equal( 1 );
 		expect( root.getChildCount() ).to.equal( 3 );
@@ -57,7 +67,13 @@ describe( 'InsertOperation', function() {
 	it( 'should insert between existing nodes', function() {
 		root.insertChildren( 0, 'xy' );
 
-		doc.applyOperation( new InsertOperation( new Position( [ 1 ], root ), 'bar', doc.version ) );
+		doc.applyOperation(
+			new InsertOperation(
+				new Position( [ 1 ], root ),
+				'bar',
+				doc.version
+			)
+		);
 
 		expect( doc.version ).to.equal( 1 );
 		expect( root.getChildCount() ).to.equal( 5 );
@@ -69,10 +85,13 @@ describe( 'InsertOperation', function() {
 	} );
 
 	it( 'should insert text', function() {
-		doc.applyOperation( new InsertOperation(
-			new Position( [ 0 ], root ),
-			[ 'foo', new Character( 'x' ), 'bar' ],
-			doc.version ) );
+		doc.applyOperation(
+			new InsertOperation(
+				new Position( [ 0 ], root ),
+				[ 'foo', new Character( 'x' ), 'bar' ],
+				doc.version
+			)
+		);
 
 		expect( doc.version ).to.equal( 1 );
 		expect( root.getChildCount() ).to.equal( 7 );
@@ -87,7 +106,11 @@ describe( 'InsertOperation', function() {
 
 	it( 'should create a remove operation as a reverse', function() {
 		var position = new Position( [ 0 ], root );
-		var operation = new InsertOperation( position, [ 'foo', new Character( 'x' ), 'bar' ], 0 );
+		var operation = new InsertOperation(
+			position,
+			[ 'foo', new Character( 'x' ), 'bar' ],
+			0
+		);
 
 		var reverse = operation.reverseOperation();
 
@@ -101,7 +124,8 @@ describe( 'InsertOperation', function() {
 		var operation = new InsertOperation(
 			new Position( [ 0 ], root ),
 			new Character( 'x' ),
-			doc.version );
+			doc.version
+		);
 
 		var reverse = operation.reverseOperation();
 
@@ -116,7 +140,11 @@ describe( 'InsertOperation', function() {
 	} );
 
 	it( 'should undo insert set of nodes by applying reverse operation', function() {
-		var operation = new InsertOperation( new Position( [ 0 ], root ), 'bar', doc.version );
+		var operation = new InsertOperation(
+			new Position( [ 0 ], root ),
+			'bar',
+			doc.version
+		);
 
 		var reverse = operation.reverseOperation();
 

+ 27 - 19
packages/ckeditor5-utils/tests/document/moveoperation.js

@@ -151,16 +151,18 @@ describe( 'MoveOperation', function() {
 	it( 'should throw an error if number of nodes to move exceeds the number of existing nodes in given element', function() {
 		root.insertChildren( 0, 'xbarx' );
 
-		expect( function() {
-			doc.applyOperation(
-				new MoveOperation(
-					new Position( [ 3 ], root ),
-					new Position( [ 1 ], root ),
-					3,
-					doc.version
-				)
-			);
-		} ).to.throw( CKEditorError, /operation-move-nodes-do-not-exist/ );
+		expect(
+			function() {
+				doc.applyOperation(
+					new MoveOperation(
+						new Position( [ 3 ], root ),
+						new Position( [ 1 ], root ),
+						3,
+						doc.version
+					)
+				);
+			}
+		).to.throw( CKEditorError, /operation-move-nodes-do-not-exist/ );
 	} );
 
 	it( 'should throw an error if target or source parent-element specified by position does not exist', function() {
@@ -177,9 +179,11 @@ describe( 'MoveOperation', function() {
 
 		root.removeChildren( 2, 1 );
 
-		expect( function() {
-			doc.applyOperation( operation );
-		} ).to.throw( CKEditorError, /operation-move-position-invalid/ );
+		expect(
+			function() {
+				doc.applyOperation( operation );
+			}
+		).to.throw( CKEditorError, /operation-move-position-invalid/ );
 	} );
 
 	it( 'should throw an error if operation tries to move a range between the beginning and the end of that range', function() {
@@ -192,9 +196,11 @@ describe( 'MoveOperation', function() {
 			doc.version
 		);
 
-		expect( function() {
-			doc.applyOperation( operation );
-		} ).to.throw( CKEditorError, /operation-move-range-into-itself/ );
+		expect(
+			function() {
+				doc.applyOperation( operation );
+			}
+		).to.throw( CKEditorError, /operation-move-range-into-itself/ );
 	} );
 
 	it( 'should throw an error if operation tries to move a range into a sub-tree of a node that is in that range', function() {
@@ -208,8 +214,10 @@ describe( 'MoveOperation', function() {
 			doc.version
 		);
 
-		expect( function() {
-			doc.applyOperation( operation );
-		} ).to.throw( CKEditorError, /operation-move-node-into-itself/ );
+		expect(
+			function() {
+				doc.applyOperation( operation );
+			}
+		).to.throw( CKEditorError, /operation-move-node-into-itself/ );
 	} );
 } );

+ 2 - 1
packages/ckeditor5-utils/tests/document/node.js

@@ -11,7 +11,8 @@ var modules = bender.amd.require(
 	'document/element',
 	'document/character',
 	'document/attribute',
-	'document/nodelist' );
+	'document/nodelist'
+);
 
 describe( 'Node', function() {
 	var Element, Character, Attribute, NodeList;

+ 2 - 1
packages/ckeditor5-utils/tests/document/nodelist.js

@@ -11,7 +11,8 @@ var modules = bender.amd.require(
 	'document/nodelist',
 	'document/character',
 	'document/text',
-	'document/attribute' );
+	'document/attribute'
+);
 
 describe( 'NodeList', function() {
 	var NodeList, Character, Text, Attribute;

+ 12 - 7
packages/ckeditor5-utils/tests/document/position.js

@@ -13,7 +13,8 @@ var modules = bender.amd.require(
 	'document/position',
 	'document/document',
 	'ckeditorerror',
-	'document/nodelist' );
+	'document/nodelist'
+);
 
 describe( 'position', function() {
 	var Element, Character, Document, NodeList, Position, CKEditorError;
@@ -105,9 +106,11 @@ describe( 'position', function() {
 	} );
 
 	it( 'should throw error if one try to make positions before root', function() {
-		expect( function() {
-			Position.createBefore( root );
-		} ).to.throw( CKEditorError, /position-before-root/ );
+		expect(
+			function() {
+				Position.createBefore( root );
+			}
+		).to.throw( CKEditorError, /position-before-root/ );
 	} );
 
 	it( 'should make positions after elements', function() {
@@ -129,9 +132,11 @@ describe( 'position', function() {
 	} );
 
 	it( 'should throw error if one try to make positions after root', function() {
-		expect( function() {
-			Position.createAfter( root );
-		} ).to.throw( CKEditorError, /position-after-root/ );
+		expect(
+			function() {
+				Position.createAfter( root );
+			}
+		).to.throw( CKEditorError, /position-after-root/ );
 	} );
 
 	it( 'should have parent', function() {

+ 13 - 12
packages/ckeditor5-utils/tests/document/positioniterator.js

@@ -13,7 +13,8 @@ var modules = bender.amd.require(
 	'document/character',
 	'document/positioniterator',
 	'document/position',
-	'document/range' );
+	'document/range'
+);
 
 describe( 'range iterator', function() {
 	var Document, Element, Character, PositionIterator, Position, Range;
@@ -59,17 +60,17 @@ describe( 'range iterator', function() {
 		root.insertChildren( 0, [ img1, paragraph ] );
 
 		expectedItems = [
-				{ type: ELEMENT_ENTER, node: img1 },
-				{ type: ELEMENT_LEAVE, node: img1 },
-				{ type: ELEMENT_ENTER, node: paragraph },
-				{ type: CHARACTER, node: b },
-				{ type: CHARACTER, node: a },
-				{ type: CHARACTER, node: r },
-				{ type: ELEMENT_ENTER, node: img2 },
-				{ type: ELEMENT_LEAVE, node: img2 },
-				{ type: CHARACTER, node: x },
-				{ type: ELEMENT_LEAVE, node: paragraph }
-			];
+			{ type: ELEMENT_ENTER, node: img1 },
+			{ type: ELEMENT_LEAVE, node: img1 },
+			{ type: ELEMENT_ENTER, node: paragraph },
+			{ type: CHARACTER, node: b },
+			{ type: CHARACTER, node: a },
+			{ type: CHARACTER, node: r },
+			{ type: ELEMENT_ENTER, node: img2 },
+			{ type: ELEMENT_LEAVE, node: img2 },
+			{ type: CHARACTER, node: x },
+			{ type: ELEMENT_LEAVE, node: paragraph }
+		];
 	} );
 
 	it( 'should return next position', function() {

+ 3 - 2
packages/ckeditor5-utils/tests/document/text.js

@@ -11,7 +11,8 @@
 
 var modules = bender.amd.require(
 	'document/text',
-	'document/attribute' );
+	'document/attribute'
+);
 
 describe( 'Text', function() {
 	describe( 'constructor', function() {
@@ -26,5 +27,5 @@ describe( 'Text', function() {
 			expect( text ).to.have.property( 'attrs' ).that.is.an( 'array' );
 			expect( text.attrs ).to.be.deep.equals( attrs );
 		} );
-	} )
+	} );
 } );