Sfoglia il codice sorgente

Fix upcoming ESLint problems in tests.

Maciej Gołaszewski 5 anni fa
parent
commit
b8269ee376

+ 50 - 46
packages/ckeditor5-engine/tests/conversion/conversion.js

@@ -154,15 +154,15 @@ describe( 'Conversion', () => {
 			it( 'config.view is a string', () => {
 				conversion.elementToElement( { model: 'paragraph', view: 'p' } );
 
-				test( '<p>Foo</p>', '<paragraph>Foo</paragraph>' );
+				testConversion( '<p>Foo</p>', '<paragraph>Foo</paragraph>' );
 			} );
 
 			it( 'config.converterPriority is defined (override downcast)', () => {
 				conversion.elementToElement( { model: 'paragraph', view: 'p' } );
 				conversion.elementToElement( { model: 'paragraph', view: 'div', converterPriority: 'high' } );
 
-				test( '<div>Foo</div>', '<paragraph>Foo</paragraph>' );
-				test( '<p>Foo</p>', '<paragraph>Foo</paragraph>', '<div>Foo</div>' );
+				testConversion( '<div>Foo</div>', '<paragraph>Foo</paragraph>' );
+				testConversion( '<p>Foo</p>', '<paragraph>Foo</paragraph>', '<div>Foo</div>' );
 			} );
 
 			it( 'config.converterPriority is defined (override upcast)', () => {
@@ -172,7 +172,7 @@ describe( 'Conversion', () => {
 				conversion.elementToElement( { model: 'paragraph', view: 'p' } );
 				conversion.elementToElement( { model: 'foo', view: 'p', converterPriority: 'high' } );
 
-				test( '<p>Foo</p>', '<foo>Foo</foo>', '<p>Foo</p>' );
+				testConversion( '<p>Foo</p>', '<foo>Foo</foo>', '<p>Foo</p>' );
 			} );
 
 			it( 'config.view is an object', () => {
@@ -188,7 +188,7 @@ describe( 'Conversion', () => {
 					}
 				} );
 
-				test( '<p class="fancy">Foo</p>', '<fancyParagraph>Foo</fancyParagraph>' );
+				testConversion( '<p class="fancy">Foo</p>', '<fancyParagraph>Foo</fancyParagraph>' );
 			} );
 
 			it( 'config.view is an object with upcastAlso defined', () => {
@@ -206,9 +206,9 @@ describe( 'Conversion', () => {
 					]
 				} );
 
-				test( '<p>Foo</p>', '<paragraph>Foo</paragraph>' );
-				test( '<div>Foo</div>', '<paragraph>Foo</paragraph>', '<p>Foo</p>' );
-				test( '<span style="display:block">Foo</span>', '<paragraph>Foo</paragraph>', '<p>Foo</p>' );
+				testConversion( '<p>Foo</p>', '<paragraph>Foo</paragraph>' );
+				testConversion( '<div>Foo</div>', '<paragraph>Foo</paragraph>', '<p>Foo</p>' );
+				testConversion( '<span style="display:block">Foo</span>', '<paragraph>Foo</paragraph>', '<p>Foo</p>' );
 			} );
 
 			it( 'upcastAlso given as a function', () => {
@@ -247,11 +247,11 @@ describe( 'Conversion', () => {
 					view: 'p'
 				} );
 
-				test( '<p></p>', '<paragraph></paragraph>' );
-				test( '<p style="font-size:20px"></p>', '<paragraph></paragraph>', '<p></p>' );
+				testConversion( '<p></p>', '<paragraph></paragraph>' );
+				testConversion( '<p style="font-size:20px"></p>', '<paragraph></paragraph>', '<p></p>' );
 
-				test( '<h2></h2>', '<heading></heading>' );
-				test( '<p style="font-size:26px"></p>', '<heading></heading>', '<h2></h2>' );
+				testConversion( '<h2></h2>', '<heading></heading>' );
+				testConversion( '<p style="font-size:26px"></p>', '<heading></heading>', '<h2></h2>' );
 			} );
 		} );
 
@@ -263,15 +263,19 @@ describe( 'Conversion', () => {
 			it( 'config.view is a string', () => {
 				conversion.attributeToElement( { model: 'bold', view: 'strong' } );
 
-				test( '<p><strong>Foo</strong> bar</p>', '<paragraph><$text bold="true">Foo</$text> bar</paragraph>' );
+				testConversion( '<p><strong>Foo</strong> bar</p>', '<paragraph><$text bold="true">Foo</$text> bar</paragraph>' );
 			} );
 
 			it( 'config.converterPriority is defined (override downcast)', () => {
 				conversion.attributeToElement( { model: 'bold', view: 'strong' } );
 				conversion.attributeToElement( { model: 'bold', view: 'b', converterPriority: 'high' } );
 
-				test( '<p><b>Foo</b></p>', '<paragraph><$text bold="true">Foo</$text></paragraph>' );
-				test( '<p><strong>Foo</strong></p>', '<paragraph><$text bold="true">Foo</$text></paragraph>', '<p><b>Foo</b></p>' );
+				testConversion( '<p><b>Foo</b></p>', '<paragraph><$text bold="true">Foo</$text></paragraph>' );
+				testConversion(
+					'<p><strong>Foo</strong></p>',
+					'<paragraph><$text bold="true">Foo</$text></paragraph>',
+					'<p><b>Foo</b></p>'
+				);
 			} );
 
 			it( 'config.converterPriority is defined (override upcast)', () => {
@@ -281,7 +285,7 @@ describe( 'Conversion', () => {
 				conversion.attributeToElement( { model: 'bold', view: 'strong' } );
 				conversion.attributeToElement( { model: 'foo', view: 'strong', converterPriority: 'high' } );
 
-				test(
+				testConversion(
 					'<p><strong>Foo</strong></p>',
 					'<paragraph><$text foo="true">Foo</$text></paragraph>',
 					'<p><strong>Foo</strong></p>'
@@ -297,7 +301,7 @@ describe( 'Conversion', () => {
 					}
 				} );
 
-				test( '<p><span class="bold">Foo</span> bar</p>', '<paragraph><$text bold="true">Foo</$text> bar</paragraph>' );
+				testConversion( '<p><span class="bold">Foo</span> bar</p>', '<paragraph><$text bold="true">Foo</$text> bar</paragraph>' );
 			} );
 
 			it( 'config.view is an object with upcastAlso defined', () => {
@@ -333,48 +337,48 @@ describe( 'Conversion', () => {
 					]
 				} );
 
-				test(
+				testConversion(
 					'<p><strong>Foo</strong></p>',
 					'<paragraph><$text bold="true">Foo</$text></paragraph>'
 				);
 
-				test(
+				testConversion(
 					'<p><b>Foo</b></p>',
 					'<paragraph><$text bold="true">Foo</$text></paragraph>',
 					'<p><strong>Foo</strong></p>'
 				);
 
-				test(
+				testConversion(
 					'<p><span class="bold">Foo</span></p>',
 					'<paragraph><$text bold="true">Foo</$text></paragraph>',
 					'<p><strong>Foo</strong></p>'
 				);
 
-				test(
+				testConversion(
 					'<p><span style="font-weight: bold;">Foo</span></p>',
 					'<paragraph><$text bold="true">Foo</$text></paragraph>',
 					'<p><strong>Foo</strong></p>'
 				);
 
-				test(
+				testConversion(
 					'<p><span style="font-weight: 500;">Foo</span></p>',
 					'<paragraph>Foo</paragraph>',
 					'<p>Foo</p>'
 				);
 
-				test(
+				testConversion(
 					'<p><span style="font-weight: 600;">Foo</span></p>',
 					'<paragraph><$text bold="true">Foo</$text></paragraph>',
 					'<p><strong>Foo</strong></p>'
 				);
 
-				test(
+				testConversion(
 					'<p style="font-weight: 600;">Foo</p>',
 					'<paragraph><$text bold="true">Foo</$text></paragraph>',
 					'<p><strong>Foo</strong></p>'
 				);
 
-				test(
+				testConversion(
 					'<p><x-bold style="font-wieght:bold">Foo</x-bold></p>',
 					'<paragraph><$text xBold="true">Foo</$text></paragraph>',
 					'<p><x-bold>Foo</x-bold></p>'
@@ -451,29 +455,29 @@ describe( 'Conversion', () => {
 					}
 				} );
 
-				test(
+				testConversion(
 					'<p><span style="font-size:1.2em">Foo</span> bar</p>',
 					'<paragraph><$text fontSize="big">Foo</$text> bar</paragraph>'
 				);
 
-				test(
+				testConversion(
 					'<p><span style="font-size:12px">Foo</span> bar</p>',
 					'<paragraph><$text fontSize="big">Foo</$text> bar</paragraph>',
 					'<p><span style="font-size:1.2em">Foo</span> bar</p>'
 				);
 
-				test(
+				testConversion(
 					'<p><span style="font-size:0.8em">Foo</span> bar</p>',
 					'<paragraph><$text fontSize="small">Foo</$text> bar</paragraph>'
 				);
 
-				test(
+				testConversion(
 					'<p><span style="font-size:8px">Foo</span> bar</p>',
 					'<paragraph><$text fontSize="small">Foo</$text> bar</paragraph>',
 					'<p><span style="font-size:0.8em">Foo</span> bar</p>'
 				);
 
-				test(
+				testConversion(
 					'<p><span style="font-size:10px">Foo</span> bar</p>',
 					'<paragraph>Foo bar</paragraph>',
 					'<p>Foo bar</p>'
@@ -507,17 +511,17 @@ describe( 'Conversion', () => {
 					}
 				} );
 
-				test(
+				testConversion(
 					'<p><span style="text-decoration:underline">Foo</span></p>',
 					'<paragraph><$text textDecoration="underline">Foo</$text></paragraph>'
 				);
 
-				test(
+				testConversion(
 					'<p><span style="text-decoration:line-through">Foo</span></p>',
 					'<paragraph><$text textDecoration="lineThrough">Foo</$text></paragraph>'
 				);
 
-				test(
+				testConversion(
 					'<p><span style="text-decoration:underline">Foo</span></p>',
 					'<paragraph><$text textDecoration="underline">Foo</$text></paragraph>'
 				);
@@ -540,7 +544,7 @@ describe( 'Conversion', () => {
 
 				conversion.attributeToAttribute( { model: 'source', view: 'src' } );
 
-				test( '<img src="foo.jpg"></img>', '<image source="foo.jpg"></image>' );
+				testConversion( '<img src="foo.jpg"></img>', '<image source="foo.jpg"></image>' );
 			} );
 
 			it( 'config.view and config.model are objects', () => {
@@ -565,8 +569,8 @@ describe( 'Conversion', () => {
 
 				conversion.elementToElement( { model: 'paragraph', view: 'p' } );
 
-				test( '<img class="aside half-size"></img>', '<image aside="aside"></image>' );
-				test( '<p class="aside half-size"></p>', '<paragraph></paragraph>', '<p></p>' );
+				testConversion( '<img class="aside half-size"></img>', '<image aside="aside"></image>' );
+				testConversion( '<p class="aside half-size"></p>', '<paragraph></paragraph>', '<p></p>' );
 			} );
 
 			it( 'config.view and config.model are objects - convert to style attribute', () => {
@@ -595,8 +599,8 @@ describe( 'Conversion', () => {
 
 				conversion.elementToElement( { model: 'paragraph', view: 'p' } );
 
-				test( '<img style="float:right;margin:5px;width:50%"></img>', '<image aside="aside"></image>' );
-				test( '<p style="float:right;margin:5px;width:50%"></p>', '<paragraph></paragraph>', '<p></p>' );
+				testConversion( '<img style="float:right;margin:5px;width:50%"></img>', '<image aside="aside"></image>' );
+				testConversion( '<p style="float:right;margin:5px;width:50%"></p>', '<paragraph></paragraph>', '<p></p>' );
 			} );
 
 			it( 'config is an array with upcastAlso defined', () => {
@@ -635,23 +639,23 @@ describe( 'Conversion', () => {
 					}
 				} );
 
-				test(
+				testConversion(
 					'<p class="align-right">Foo</p>',
 					'<paragraph align="right">Foo</paragraph>'
 				);
 
-				test(
+				testConversion(
 					'<p style="text-align:right">Foo</p>',
 					'<paragraph align="right">Foo</paragraph>',
 					'<p class="align-right">Foo</p>'
 				);
 
-				test(
+				testConversion(
 					'<p class="align-center">Foo</p>',
 					'<paragraph align="center">Foo</paragraph>'
 				);
 
-				test(
+				testConversion(
 					'<p style="text-align:center">Foo</p>',
 					'<paragraph align="center">Foo</paragraph>',
 					'<p class="align-center">Foo</p>'
@@ -674,7 +678,7 @@ describe( 'Conversion', () => {
 					}
 				} );
 
-				test( '<img src="foo.jpg"></img>', '<image source="foo.jpg"></image>' );
+				testConversion( '<img src="foo.jpg"></img>', '<image source="foo.jpg"></image>' );
 			} );
 
 			// #1443.
@@ -693,7 +697,7 @@ describe( 'Conversion', () => {
 				conversion.attributeToAttribute( { model: 'border', view: { key: 'class', value: 'border' } } );
 				conversion.attributeToAttribute( { model: 'shade', view: { key: 'class', value: 'shade' } } );
 
-				test(
+				testConversion(
 					'<div class="border"><div class="shade"></div></div>',
 					'<div border="border"><div shade="shade"></div></div>'
 				);
@@ -707,11 +711,11 @@ describe( 'Conversion', () => {
 				conversion.attributeToAttribute( { model: 'foo', view: 'foo' } );
 				conversion.attributeToAttribute( { model: 'foo', view: 'foofoo', converterPriority: 'high' } );
 
-				test( '<img foo="foo"></img>', '<image foo="foo"></image>', '<img foofoo="foo"></img>' );
+				testConversion( '<img foo="foo"></img>', '<image foo="foo"></image>', '<img foofoo="foo"></img>' );
 			} );
 		} );
 
-		function test( input, expectedModel, expectedView = null ) {
+		function testConversion( input, expectedModel, expectedView = null ) {
 			loadData( input );
 
 			expect( modelStringify( model.document.getRoot() ) ).to.equal( expectedModel );

+ 24 - 24
packages/ckeditor5-engine/tests/conversion/downcasthelpers.js

@@ -1810,7 +1810,7 @@ describe( 'downcast selection converters', () => {
 	describe( 'default converters', () => {
 		describe( 'range selection', () => {
 			it( 'in same container', () => {
-				test(
+				testSelection(
 					[ 1, 4 ],
 					'foobar',
 					'f{oob}ar'
@@ -1818,7 +1818,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'in same container with unicode characters', () => {
-				test(
+				testSelection(
 					[ 2, 6 ],
 					'நிலைக்கு',
 					'நி{லைக்}கு'
@@ -1826,7 +1826,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'in same container, over attribute', () => {
-				test(
+				testSelection(
 					[ 1, 5 ],
 					'fo<$text bold="true">ob</$text>ar',
 					'f{o<strong>ob</strong>a}r'
@@ -1834,7 +1834,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'in same container, next to attribute', () => {
-				test(
+				testSelection(
 					[ 1, 2 ],
 					'fo<$text bold="true">ob</$text>ar',
 					'f{o}<strong>ob</strong>ar'
@@ -1842,7 +1842,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'in same attribute', () => {
-				test(
+				testSelection(
 					[ 2, 4 ],
 					'f<$text bold="true">ooba</$text>r',
 					'f<strong>o{ob}a</strong>r'
@@ -1850,7 +1850,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'in same attribute, selection same as attribute', () => {
-				test(
+				testSelection(
 					[ 2, 4 ],
 					'fo<$text bold="true">ob</$text>ar',
 					'fo{<strong>ob</strong>}ar'
@@ -1858,7 +1858,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'starts in text node, ends in attribute #1', () => {
-				test(
+				testSelection(
 					[ 1, 3 ],
 					'fo<$text bold="true">ob</$text>ar',
 					'f{o<strong>o}b</strong>ar'
@@ -1866,7 +1866,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'starts in text node, ends in attribute #2', () => {
-				test(
+				testSelection(
 					[ 1, 4 ],
 					'fo<$text bold="true">ob</$text>ar',
 					'f{o<strong>ob</strong>}ar'
@@ -1874,7 +1874,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'starts in attribute, ends in text node', () => {
-				test(
+				testSelection(
 					[ 3, 5 ],
 					'fo<$text bold="true">ob</$text>ar',
 					'fo<strong>o{b</strong>a}r'
@@ -1889,7 +1889,7 @@ describe( 'downcast selection converters', () => {
 				}, { priority: 'high' } );
 
 				// Similar test case as the first in this suite.
-				test(
+				testSelection(
 					[ 1, 4 ],
 					'foobar',
 					'foobar' // No selection in view.
@@ -1897,7 +1897,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'should convert backward selection', () => {
-				test(
+				testSelection(
 					[ 1, 3, 'backward' ],
 					'foobar',
 					'f{oo}bar'
@@ -1911,7 +1911,7 @@ describe( 'downcast selection converters', () => {
 			let marker;
 
 			it( 'in container', () => {
-				test(
+				testSelection(
 					[ 1, 1 ],
 					'foobar',
 					'f{}oobar'
@@ -1919,7 +1919,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'in attribute', () => {
-				test(
+				testSelection(
 					[ 3, 3 ],
 					'f<$text bold="true">ooba</$text>r',
 					'f<strong>oo{}ba</strong>r'
@@ -2120,7 +2120,7 @@ describe( 'downcast selection converters', () => {
 				}, { priority: 'high' } );
 
 				// Similar test case as above.
-				test(
+				testSelection(
 					[ 3, 3 ],
 					'f<$text bold="true">ooba</$text>r',
 					'foobar' // No selection in view and no attribute.
@@ -2132,13 +2132,13 @@ describe( 'downcast selection converters', () => {
 	describe( 'clean-up', () => {
 		describe( 'convertRangeSelection', () => {
 			it( 'should remove all ranges before adding new range', () => {
-				test(
+				testSelection(
 					[ 0, 2 ],
 					'foobar',
 					'{fo}obar'
 				);
 
-				test(
+				testSelection(
 					[ 3, 5 ],
 					'foobar',
 					'foo{ba}r'
@@ -2150,13 +2150,13 @@ describe( 'downcast selection converters', () => {
 
 		describe( 'convertCollapsedSelection', () => {
 			it( 'should remove all ranges before adding new range', () => {
-				test(
+				testSelection(
 					[ 2, 2 ],
 					'foobar',
 					'fo{}obar'
 				);
 
-				test(
+				testSelection(
 					[ 3, 3 ],
 					'foobar',
 					'foo{}bar'
@@ -2168,7 +2168,7 @@ describe( 'downcast selection converters', () => {
 
 		describe( 'clearAttributes', () => {
 			it( 'should remove all ranges before adding new range', () => {
-				test(
+				testSelection(
 					[ 3, 3 ],
 					'foobar',
 					'foo<strong>[]</strong>bar',
@@ -2191,7 +2191,7 @@ describe( 'downcast selection converters', () => {
 			} );
 
 			it( 'should do nothing if the attribute element had been already removed', () => {
-				test(
+				testSelection(
 					[ 3, 3 ],
 					'foobar',
 					'foo<strong>[]</strong>bar',
@@ -2269,7 +2269,7 @@ describe( 'downcast selection converters', () => {
 		} );
 
 		it( 'should not be used to convert selection that is not on table cell', () => {
-			test(
+			testSelection(
 				[ 1, 5 ],
 				'f{o<$text bold="true">ob</$text>a}r',
 				'f{o<strong>ob</strong>a}r'
@@ -2277,7 +2277,7 @@ describe( 'downcast selection converters', () => {
 		} );
 
 		it( 'should add a class to the selected table cell', () => {
-			test(
+			testSelection(
 				// table tr#0 td#0 [foo, table tr#0 td#0 bar]
 				[ [ 0, 0, 0, 0 ], [ 0, 0, 0, 3 ] ],
 				'<table><tr><td>foo</td></tr><tr><td>bar</td></tr></table>',
@@ -2286,7 +2286,7 @@ describe( 'downcast selection converters', () => {
 		} );
 
 		it( 'should not be used if selection contains more than just a table cell', () => {
-			test(
+			testSelection(
 				// table tr td#1 f{oo bar, table tr#2 bar]
 				[ [ 0, 0, 0, 1 ], [ 0, 0, 1, 3 ] ],
 				'<table><tr><td>foo</td><td>bar</td></tr></table>',
@@ -2300,7 +2300,7 @@ describe( 'downcast selection converters', () => {
 	// to set the selection (because then we would test converters using converters).
 	// Instead, the `test` function expects to be passed `selectionPaths` which is an array containing two numbers or two arrays,
 	// that are offsets or paths of selection positions in root element.
-	function test( selectionPaths, modelInput, expectedView, selectionAttributes = {} ) {
+	function testSelection( selectionPaths, modelInput, expectedView, selectionAttributes = {} ) {
 		// Parse passed `modelInput` string and set it as current model.
 		setModelData( model, modelInput );
 

+ 11 - 11
packages/ckeditor5-engine/tests/dev-utils/model.js

@@ -131,43 +131,43 @@ describe( 'model test utils', () => {
 		} );
 
 		it( 'should insert text', () => {
-			test( 'this is test text', '[]this is test text' );
+			testUtils( 'this is test text', '[]this is test text' );
 		} );
 
 		it( 'should insert text with selection around', () => {
-			test( '[this is test text]' );
+			testUtils( '[this is test text]' );
 		} );
 
 		it( 'should insert text with selection inside #1', () => {
-			test( 'this [is test] text' );
+			testUtils( 'this [is test] text' );
 		} );
 
 		it( 'should insert text with selection inside #2', () => {
-			test( '[this is test] text' );
+			testUtils( '[this is test] text' );
 		} );
 
 		it( 'should insert text with selection inside #3', () => {
-			test( 'this is [test text]' );
+			testUtils( 'this is [test text]' );
 		} );
 
 		it( 'should insert unicode text with selection', () => {
-			test( 'நி[லைக்]கு' );
+			testUtils( 'நி[லைக்]கு' );
 		} );
 
 		it( 'should insert element', () => {
-			test( '<b>foo bar</b>', '[]<b>foo bar</b>' );
+			testUtils( '<b>foo bar</b>', '[]<b>foo bar</b>' );
 		} );
 
 		it( 'should insert element with selection inside #1', () => {
-			test( '<b>[foo ]bar</b>' );
+			testUtils( '<b>[foo ]bar</b>' );
 		} );
 
 		it( 'should insert element with selection inside #2', () => {
-			test( '[<b>foo ]bar</b>' );
+			testUtils( '[<b>foo ]bar</b>' );
 		} );
 
 		it( 'should insert element with selection inside #3', () => {
-			test( '<b>[foo bar</b>]' );
+			testUtils( '<b>[foo bar</b>]' );
 		} );
 
 		it( 'should insert backward selection', () => {
@@ -201,7 +201,7 @@ describe( 'model test utils', () => {
 			expect( getData( model, { rootName: 'textOnly' } ) ).to.equal( 'a[b]c' );
 		} );
 
-		function test( data, expected ) {
+		function testUtils( data, expected ) {
 			expected = expected || data;
 
 			setData( model, data );

+ 8 - 8
packages/ckeditor5-engine/tests/model/position.js

@@ -1209,14 +1209,14 @@ describe( 'Position', () => {
 			const pos1 = new Position( root, [ 0 ] );
 			const pos2 = new Position( otherRoot, [ 0 ] );
 
-			test( pos1, pos2, null );
+			testAncestor( pos1, pos2, null );
 		} );
 
 		it( 'for two the same positions returns the parent element #1', () => {
 			const fPosition = new Position( root, [ 1, 0, 0 ] );
 			const otherPosition = new Position( root, [ 1, 0, 0 ] );
 
-			test( fPosition, otherPosition, li1 );
+			testAncestor( fPosition, otherPosition, li1 );
 		} );
 
 		it( 'for two the same positions returns the parent element #2', () => {
@@ -1230,21 +1230,21 @@ describe( 'Position', () => {
 
 			const postion = new Position( root, [ 0, 3 ] ); // <p>foo^bar</p>
 
-			test( postion, postion, p );
+			testAncestor( postion, postion, p );
 		} );
 
 		it( 'for two positions in the same element returns the element', () => {
 			const fPosition = new Position( root, [ 1, 0, 0 ] );
 			const zPosition = new Position( root, [ 1, 0, 2 ] );
 
-			test( fPosition, zPosition, li1 );
+			testAncestor( fPosition, zPosition, li1 );
 		} );
 
 		it( 'works when one positions is nested deeper than the other', () => {
 			const zPosition = new Position( root, [ 1, 0, 2 ] );
 			const liPosition = new Position( root, [ 1, 1 ] );
 
-			test( liPosition, zPosition, ul );
+			testAncestor( liPosition, zPosition, ul );
 		} );
 
 		// Checks if by mistake someone didn't use getCommonPath() + getNodeByPath().
@@ -1259,7 +1259,7 @@ describe( 'Position', () => {
 
 			const postion = new Position( root, [ 0, 0 ] ); // <p>^<a></a></p>
 
-			test( postion, postion, p );
+			testAncestor( postion, postion, p );
 		} );
 
 		it( 'works fine with positions located in DocumentFragment', () => {
@@ -1267,10 +1267,10 @@ describe( 'Position', () => {
 			const zPosition = new Position( docFrag, [ 1, 0, 2 ] );
 			const afterLiPosition = new Position( docFrag, [ 1, 2 ] );
 
-			test( zPosition, afterLiPosition, ul );
+			testAncestor( zPosition, afterLiPosition, ul );
 		} );
 
-		function test( positionA, positionB, lca ) {
+		function testAncestor( positionA, positionB, lca ) {
 			expect( positionA.getCommonAncestor( positionB ) ).to.equal( lca );
 			expect( positionB.getCommonAncestor( positionA ) ).to.equal( lca );
 		}

+ 5 - 5
packages/ckeditor5-engine/tests/model/writer.js

@@ -1461,22 +1461,22 @@ describe( 'Writer', () => {
 
 		describe( 'should create a marker operation if a marker was affected', () => {
 			it( '<p>Foo[</p><p>Bar]</p>', () => {
-				test( p1, 'end', p2, 0 );
+				testMerge( p1, 'end', p2, 0 );
 			} );
 
 			it( '<p>[Foo</p><p>]Bar</p>', () => {
-				test( p1, 0, p2, 0 );
+				testMerge( p1, 0, p2, 0 );
 			} );
 
 			it( '<p>[Foo</p>]<p>Bar</p>', () => {
-				test( p1, 0, root, 1 );
+				testMerge( p1, 0, root, 1 );
 			} );
 
 			it( '<p>Foo</p>[<p>Bar]</p>', () => {
-				test( root, 1, p2, 'end' );
+				testMerge( root, 1, p2, 'end' );
 			} );
 
-			function test( startElement, startOffset, endElement, endOffset ) {
+			function testMerge( startElement, startOffset, endElement, endOffset ) {
 				const markerRange = new Range(
 					Position._createAt( startElement, startOffset ),
 					Position._createAt( endElement, endOffset )

+ 128 - 128
packages/ckeditor5-engine/tests/view/domconverter/view-to-dom.js

@@ -245,7 +245,7 @@ describe( 'DomConverter', () => {
 				);
 			} );
 
-			function test( inputTexts, output ) {
+			function testConvert( inputTexts, output ) {
 				if ( typeof inputTexts == 'string' ) {
 					inputTexts = [ inputTexts ];
 				}
@@ -269,150 +269,150 @@ describe( 'DomConverter', () => {
 			}
 
 			// At the beginning.
-			test( ' x', '_x' );
-			test( '  x', '_ x' );
-			test( '   x', '_ _x' );
-			test( '    x', '_ _ x' );
+			testConvert( ' x', '_x' );
+			testConvert( '  x', '_ x' );
+			testConvert( '   x', '_ _x' );
+			testConvert( '    x', '_ _ x' );
 
 			// At the end.
-			test( 'x ', 'x_' );
-			test( 'x  ', 'x _' );
-			test( 'x   ', 'x __' );
-			test( 'x    ', 'x _ _' );
+			testConvert( 'x ', 'x_' );
+			testConvert( 'x  ', 'x _' );
+			testConvert( 'x   ', 'x __' );
+			testConvert( 'x    ', 'x _ _' );
 
 			// In the middle.
-			test( 'x x', 'x x' );
-			test( 'x  x', 'x _x' );
-			test( 'x   x', 'x _ x' );
-			test( 'x    x', 'x _ _x' );
+			testConvert( 'x x', 'x x' );
+			testConvert( 'x  x', 'x _x' );
+			testConvert( 'x   x', 'x _ x' );
+			testConvert( 'x    x', 'x _ _x' );
 
 			// Complex.
-			test( ' x ', '_x_' );
-			test( '  x  x  ', '_ x _x _' );
-			test( '   x x  ', '_ _x x _' );
-			test( '   x x   ', '_ _x x __' );
-			test( '   x    x ', '_ _x _ _x_' );
+			testConvert( ' x ', '_x_' );
+			testConvert( '  x  x  ', '_ x _x _' );
+			testConvert( '   x x  ', '_ _x x _' );
+			testConvert( '   x x   ', '_ _x x __' );
+			testConvert( '   x    x ', '_ _x _ _x_' );
 
 			// Only spaces.
-			test( ' ', '_' );
-			test( '  ', '__' );
-			test( '   ', '_ _' );
-			test( '    ', '_ __' );
-			test( '     ', '_ _ _' );
-			test( '      ', '_ _ __' );
+			testConvert( ' ', '_' );
+			testConvert( '  ', '__' );
+			testConvert( '   ', '_ _' );
+			testConvert( '    ', '_ __' );
+			testConvert( '     ', '_ _ _' );
+			testConvert( '      ', '_ _ __' );
 
 			// With hard &nbsp;
 			// It should be treated like a normal sign.
-			test( '_x', '_x' );
-			test( ' _x', '__x' );
-			test( '  _x', '_ _x' );
-			test( ' __x', '___x' );
-			test( '___x', '___x' );
-			test( '_ _x', '_ _x' );
-			test( ' _ x', '__ x' );
-			test( '  _x', '_ _x' );
-
-			test( 'x_', 'x_' );
-			test( 'x_ ', 'x__' );
-			test( 'x_  ', 'x_ _' );
-			test( 'x__ ', 'x___' );
-			test( 'x___', 'x___' );
-			test( 'x_ _', 'x_ _' );
-			test( 'x _ ', 'x __' );
-			test( 'x  _', 'x __' );
-
-			test( 'x_x', 'x_x' );
-			test( 'x___x', 'x___x' );
-			test( 'x__ x', 'x__ x' );
-			test( 'x_  x', 'x_ _x' );
-			test( 'x  _x', 'x __x' );
-			test( 'x __x', 'x __x' );
-			test( 'x _ x', 'x _ x' );
-			test( 'x  _  x', 'x __ _x' );
-
-			test( [ 'x', 'y' ], 'xy' );
-			test( [ 'x ', 'y' ], 'x y' );
-			test( [ 'x  ', 'y' ], 'x _y' );
-			test( [ 'x   ', 'y' ], 'x __y' );
-			test( [ 'x    ', 'y' ], 'x _ _y' );
-
-			test( [ 'x', ' y' ], 'x y' );
-			test( [ 'x ', ' y' ], 'x_ y' );
-			test( [ 'x  ', ' y' ], 'x _ y' );
-			test( [ 'x   ', ' y' ], 'x __ y' );
-			test( [ 'x    ', ' y' ], 'x _ _ y' );
-
-			test( [ 'x', '_y' ], 'x_y' );
-			test( [ 'x ', '_y' ], 'x _y' );
-			test( [ 'x  ', '_y' ], 'x __y' );
+			testConvert( '_x', '_x' );
+			testConvert( ' _x', '__x' );
+			testConvert( '  _x', '_ _x' );
+			testConvert( ' __x', '___x' );
+			testConvert( '___x', '___x' );
+			testConvert( '_ _x', '_ _x' );
+			testConvert( ' _ x', '__ x' );
+			testConvert( '  _x', '_ _x' );
+
+			testConvert( 'x_', 'x_' );
+			testConvert( 'x_ ', 'x__' );
+			testConvert( 'x_  ', 'x_ _' );
+			testConvert( 'x__ ', 'x___' );
+			testConvert( 'x___', 'x___' );
+			testConvert( 'x_ _', 'x_ _' );
+			testConvert( 'x _ ', 'x __' );
+			testConvert( 'x  _', 'x __' );
+
+			testConvert( 'x_x', 'x_x' );
+			testConvert( 'x___x', 'x___x' );
+			testConvert( 'x__ x', 'x__ x' );
+			testConvert( 'x_  x', 'x_ _x' );
+			testConvert( 'x  _x', 'x __x' );
+			testConvert( 'x __x', 'x __x' );
+			testConvert( 'x _ x', 'x _ x' );
+			testConvert( 'x  _  x', 'x __ _x' );
+
+			testConvert( [ 'x', 'y' ], 'xy' );
+			testConvert( [ 'x ', 'y' ], 'x y' );
+			testConvert( [ 'x  ', 'y' ], 'x _y' );
+			testConvert( [ 'x   ', 'y' ], 'x __y' );
+			testConvert( [ 'x    ', 'y' ], 'x _ _y' );
+
+			testConvert( [ 'x', ' y' ], 'x y' );
+			testConvert( [ 'x ', ' y' ], 'x_ y' );
+			testConvert( [ 'x  ', ' y' ], 'x _ y' );
+			testConvert( [ 'x   ', ' y' ], 'x __ y' );
+			testConvert( [ 'x    ', ' y' ], 'x _ _ y' );
+
+			testConvert( [ 'x', '_y' ], 'x_y' );
+			testConvert( [ 'x ', '_y' ], 'x _y' );
+			testConvert( [ 'x  ', '_y' ], 'x __y' );
 
 			// Two text nodes.
-			test( [ 'x   ', '_y' ], 'x ___y' );
-			test( [ 'x    ', '_y' ], 'x _ __y' );
-
-			test( [ 'x', '  y' ], 'x _y' );
-			test( [ 'x ', '  y' ], 'x_ _y' );
-			test( [ 'x  ', '  y' ], 'x _ _y' );
-			test( [ 'x   ', '  y' ], 'x __ _y' );
-			test( [ 'x    ', '  y' ], 'x _ _ _y' );
-
-			test( [ 'x', '   y' ], 'x _ y' );
-			test( [ 'x ', '   y' ], 'x_ _ y' );
-			test( [ 'x  ', '   y' ], 'x _ _ y' );
-			test( [ 'x   ', '   y' ], 'x __ _ y' );
-			test( [ 'x    ', '   y' ], 'x _ _ _ y' );
-
-			test( [ 'x',	' '		], 'x_' );
-			test( [ 'x',	'  '	], 'x _' );
-			test( [ 'x',	'   '	], 'x __' );
-			test( [ 'x ',	' '		], 'x__' );
-			test( [ 'x ',	'  '	], 'x_ _' );
-			test( [ 'x ',	'   '	], 'x_ __' );
-			test( [ 'x  ',	' '		], 'x __' );
-			test( [ 'x  ',	'  '	], 'x _ _' );
-			test( [ 'x  ',	'   '	], 'x _ __' );
-			test( [ 'x   ',	' '		], 'x ___' );
-			test( [ 'x   ',	'  '	], 'x __ _' );
-			test( [ 'x   ',	'   '	], 'x __ __' );
-
-			test( [ ' ',	'x'		], '_x' );
-			test( [ '  ',	'x'		], '_ x' );
-			test( [ '   ',	'x'		], '_ _x' );
-			test( [ ' ',	' x'	], '_ x' );
-			test( [ '  ',	' x'	], '__ x' );
-			test( [ '   ',	' x'	], '_ _ x' );
-			test( [ ' ',	'  x'	], '_ _x' );
-			test( [ '  ',	'  x'	], '__ _x' );
-			test( [ '   ',	'  x'	], '_ _ _x' );
-			test( [ ' ',	'   x'	], '_ _ x' );
-			test( [ '  ',	'   x'	], '__ _ x' );
-			test( [ '   ',	'   x'	], '_ _ _ x' );
+			testConvert( [ 'x   ', '_y' ], 'x ___y' );
+			testConvert( [ 'x    ', '_y' ], 'x _ __y' );
+
+			testConvert( [ 'x', '  y' ], 'x _y' );
+			testConvert( [ 'x ', '  y' ], 'x_ _y' );
+			testConvert( [ 'x  ', '  y' ], 'x _ _y' );
+			testConvert( [ 'x   ', '  y' ], 'x __ _y' );
+			testConvert( [ 'x    ', '  y' ], 'x _ _ _y' );
+
+			testConvert( [ 'x', '   y' ], 'x _ y' );
+			testConvert( [ 'x ', '   y' ], 'x_ _ y' );
+			testConvert( [ 'x  ', '   y' ], 'x _ _ y' );
+			testConvert( [ 'x   ', '   y' ], 'x __ _ y' );
+			testConvert( [ 'x    ', '   y' ], 'x _ _ _ y' );
+
+			testConvert( [ 'x',	' '		], 'x_' );
+			testConvert( [ 'x',	'  '	], 'x _' );
+			testConvert( [ 'x',	'   '	], 'x __' );
+			testConvert( [ 'x ',	' '		], 'x__' );
+			testConvert( [ 'x ',	'  '	], 'x_ _' );
+			testConvert( [ 'x ',	'   '	], 'x_ __' );
+			testConvert( [ 'x  ',	' '		], 'x __' );
+			testConvert( [ 'x  ',	'  '	], 'x _ _' );
+			testConvert( [ 'x  ',	'   '	], 'x _ __' );
+			testConvert( [ 'x   ',	' '		], 'x ___' );
+			testConvert( [ 'x   ',	'  '	], 'x __ _' );
+			testConvert( [ 'x   ',	'   '	], 'x __ __' );
+
+			testConvert( [ ' ',	'x'		], '_x' );
+			testConvert( [ '  ',	'x'		], '_ x' );
+			testConvert( [ '   ',	'x'		], '_ _x' );
+			testConvert( [ ' ',	' x'	], '_ x' );
+			testConvert( [ '  ',	' x'	], '__ x' );
+			testConvert( [ '   ',	' x'	], '_ _ x' );
+			testConvert( [ ' ',	'  x'	], '_ _x' );
+			testConvert( [ '  ',	'  x'	], '__ _x' );
+			testConvert( [ '   ',	'  x'	], '_ _ _x' );
+			testConvert( [ ' ',	'   x'	], '_ _ x' );
+			testConvert( [ '  ',	'   x'	], '__ _ x' );
+			testConvert( [ '   ',	'   x'	], '_ _ _ x' );
 
 			// "Non-empty" + "empty" text nodes.
-			test( [ 'x',	' ',		'x'		],	'x x' );
-			test( [ 'x',	' ',		' x'	],	'x_ x' );
-			test( [ 'x',	'  ',		' x'	],	'x _ x' );
-			test( [ 'x',	'   ',		'  x'	],	'x __ _x' );
-			test( [ 'x ',	' ',		' x'	],	'x__ x' );
-			test( [ 'x ',	'  ',		' x'	],	'x_ _ x' );
-			test( [ 'x ',	'   ',		'  x'	],	'x_ __ _x' );
-			test( [ 'x  ',	' ',		' x'	],	'x __ x' );
-			test( [ 'x  ',	'  ',		' x'	],	'x _ _ x' );
-			test( [ 'x  ',	'   ',		'  x'	],	'x _ __ _x' );
-			test( [ 'x   ',	' ',		' x'	],	'x ___ x' );
-			test( [ 'x   ',	'  ',		' x'	],	'x __ _ x' );
-			test( [ 'x   ',	'   ',		'  x'	],	'x __ __ _x' );
+			testConvert( [ 'x',	' ',		'x'		],	'x x' );
+			testConvert( [ 'x',	' ',		' x'	],	'x_ x' );
+			testConvert( [ 'x',	'  ',		' x'	],	'x _ x' );
+			testConvert( [ 'x',	'   ',		'  x'	],	'x __ _x' );
+			testConvert( [ 'x ',	' ',		' x'	],	'x__ x' );
+			testConvert( [ 'x ',	'  ',		' x'	],	'x_ _ x' );
+			testConvert( [ 'x ',	'   ',		'  x'	],	'x_ __ _x' );
+			testConvert( [ 'x  ',	' ',		' x'	],	'x __ x' );
+			testConvert( [ 'x  ',	'  ',		' x'	],	'x _ _ x' );
+			testConvert( [ 'x  ',	'   ',		'  x'	],	'x _ __ _x' );
+			testConvert( [ 'x   ',	' ',		' x'	],	'x ___ x' );
+			testConvert( [ 'x   ',	'  ',		' x'	],	'x __ _ x' );
+			testConvert( [ 'x   ',	'   ',		'  x'	],	'x __ __ _x' );
 
 			// "Empty" + "empty" text nodes.
-			test( [ ' ', ' ' ], '__' );
-			test( [ '  ', ' ' ], '___' );
-			test( [ '   ', ' ' ], '_ __' );
-			test( [ ' ', '  ' ], '_ _' );
-			test( [ ' ', '   ' ], '_ __' );
-			test( [ '  ', '  ' ], '__ _' );
-			test( [ '  ', '   ' ], '__ __' );
-			test( [ '   ', '  ' ], '_ _ _' );
-			test( [ '   ', '   ' ], '_ _ __' );
+			testConvert( [ ' ', ' ' ], '__' );
+			testConvert( [ '  ', ' ' ], '___' );
+			testConvert( [ '   ', ' ' ], '_ __' );
+			testConvert( [ ' ', '  ' ], '_ _' );
+			testConvert( [ ' ', '   ' ], '_ __' );
+			testConvert( [ '  ', '  ' ], '__ _' );
+			testConvert( [ '  ', '   ' ], '__ __' );
+			testConvert( [ '   ', '  ' ], '_ _ _' );
+			testConvert( [ '   ', '   ' ], '_ _ __' );
 
 			it( 'not in preformatted blocks', () => {
 				const viewPre = new ViewContainerElement( 'pre', null, [ new ViewText( '   foo   ' ), new ViewText( ' bar ' ) ] );

+ 22 - 22
packages/ckeditor5-engine/tests/view/downcastwriter/breakattributes.js

@@ -32,7 +32,7 @@ describe( 'DowncastWriter', () => {
 			 * @param {String} input
 			 * @param {String} expected
 			 */
-			function test( input, expected ) {
+			function testBreakAttributes( input, expected ) {
 				const { view, selection } = parse( input );
 
 				const newPosition = writer.breakAttributes( selection.getFirstPosition() );
@@ -43,28 +43,28 @@ describe( 'DowncastWriter', () => {
 			}
 
 			it( 'should not break text nodes if they are not in attribute elements - middle', () => {
-				test(
+				testBreakAttributes(
 					'<container:p>foo{}bar</container:p>',
 					'<container:p>foo{}bar</container:p>'
 				);
 			} );
 
 			it( 'should not break text nodes if they are not in attribute elements - beginning', () => {
-				test(
+				testBreakAttributes(
 					'<container:p>{}foobar</container:p>',
 					'<container:p>{}foobar</container:p>'
 				);
 			} );
 
 			it( 'should not break text nodes if they are not in attribute elements #2 - end', () => {
-				test(
+				testBreakAttributes(
 					'<container:p>foobar{}</container:p>',
 					'<container:p>foobar{}</container:p>'
 				);
 			} );
 
 			it( 'should split attribute element', () => {
-				test(
+				testBreakAttributes(
 					'<container:p><attribute:b view-priority="1">foo{}bar</attribute:b></container:p>',
 					'<container:p>' +
 					'<attribute:b view-priority="1">foo</attribute:b>[]<attribute:b view-priority="1">bar</attribute:b>' +
@@ -73,7 +73,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should move from beginning of the nested text node to the container', () => {
-				test(
+				testBreakAttributes(
 					'<container:p>' +
 					'<attribute:b view-priority="1"><attribute:u view-priority="1">{}foobar</attribute:u></attribute:b>' +
 					'</container:p>',
@@ -84,14 +84,14 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should stick selection in text node if it is in container', () => {
-				test(
+				testBreakAttributes(
 					'<container:p>foo{}<attribute:b view-priority="1">bar</attribute:b></container:p>',
 					'<container:p>foo{}<attribute:b view-priority="1">bar</attribute:b></container:p>'
 				);
 			} );
 
 			it( 'should split nested attributes', () => {
-				test(
+				testBreakAttributes(
 					'<container:p>' +
 					'<attribute:b view-priority="1"><attribute:u view-priority="1">foo{}bar</attribute:u></attribute:b>' +
 					'</container:p>',
@@ -112,7 +112,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should move from end of the nested text node to the container', () => {
-				test(
+				testBreakAttributes(
 					'<container:p>' +
 					'<attribute:b view-priority="1"><attribute:u view-priority="1">foobar{}</attribute:u></attribute:b>' +
 					'</container:p>',
@@ -123,14 +123,14 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should split attribute element directly in document fragment', () => {
-				test(
+				testBreakAttributes(
 					'<attribute:b view-priority="1">foo{}bar</attribute:b>',
 					'<attribute:b view-priority="1">foo</attribute:b>[]<attribute:b view-priority="1">bar</attribute:b>'
 				);
 			} );
 
 			it( 'should not split text directly in document fragment', () => {
-				test(
+				testBreakAttributes(
 					'foo{}bar',
 					'foo{}bar'
 				);
@@ -144,7 +144,7 @@ describe( 'DowncastWriter', () => {
 			 * @param {String} input
 			 * @param {String} expected
 			 */
-			function test( input, expected ) {
+			function testBreak( input, expected ) {
 				const { view, selection } = parse( input );
 
 				const newRange = writer.breakAttributes( selection.getFirstRange() );
@@ -169,21 +169,21 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should not break text nodes if they are not in attribute elements', () => {
-				test(
+				testBreak(
 					'<container:p>foo{}bar</container:p>',
 					'<container:p>foo{}bar</container:p>'
 				);
 			} );
 
 			it( 'should break at collapsed range and return collapsed one', () => {
-				test(
+				testBreak(
 					'<container:p><attribute:b>foo{}bar</attribute:b></container:p>',
 					'<container:p><attribute:b>foo</attribute:b>[]<attribute:b>bar</attribute:b></container:p>'
 				);
 			} );
 
 			it( 'should break inside text node #1', () => {
-				test(
+				testBreak(
 					'<container:p><attribute:b>foo{bar}baz</attribute:b></container:p>',
 					'<container:p>' +
 						'<attribute:b>foo</attribute:b>[<attribute:b>bar</attribute:b>]<attribute:b>baz</attribute:b>' +
@@ -192,49 +192,49 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should break inside text node #2', () => {
-				test(
+				testBreak(
 					'<container:p><attribute:b>foo{barbaz}</attribute:b></container:p>',
 					'<container:p><attribute:b>foo</attribute:b>[<attribute:b>barbaz</attribute:b>]</container:p>'
 				);
 			} );
 
 			it( 'should break inside text node #3', () => {
-				test(
+				testBreak(
 					'<container:p><attribute:b>foo{barbaz]</attribute:b></container:p>',
 					'<container:p><attribute:b>foo</attribute:b>[<attribute:b>barbaz</attribute:b>]</container:p>'
 				);
 			} );
 
 			it( 'should break inside text node #4', () => {
-				test(
+				testBreak(
 					'<container:p><attribute:b>{foo}barbaz</attribute:b></container:p>',
 					'<container:p>[<attribute:b>foo</attribute:b>]<attribute:b>barbaz</attribute:b></container:p>'
 				);
 			} );
 
 			it( 'should break inside text node #5', () => {
-				test(
+				testBreak(
 					'<container:p><attribute:b>[foo}barbaz</attribute:b></container:p>',
 					'<container:p>[<attribute:b>foo</attribute:b>]<attribute:b>barbaz</attribute:b></container:p>'
 				);
 			} );
 
 			it( 'should break placed inside different nodes', () => {
-				test(
+				testBreak(
 					'<container:p>foo{bar<attribute:b>baz}qux</attribute:b></container:p>',
 					'<container:p>foo{bar<attribute:b>baz</attribute:b>]<attribute:b>qux</attribute:b></container:p>'
 				);
 			} );
 
 			it( 'should split attribute element directly in document fragment', () => {
-				test(
+				testBreak(
 					'<attribute:b>fo{ob}ar</attribute:b>',
 					'<attribute:b>fo</attribute:b>[<attribute:b>ob</attribute:b>]<attribute:b>ar</attribute:b>'
 				);
 			} );
 
 			it( 'should not split text directly in document fragment', () => {
-				test(
+				testBreak(
 					'foo{}bar',
 					'foo{}bar'
 				);

+ 4 - 4
packages/ckeditor5-engine/tests/view/downcastwriter/breakcontainer.js

@@ -20,7 +20,7 @@ describe( 'DowncastWriter', () => {
 		//
 		// @param {String} input
 		// @param {String} expected
-		function test( input, expected ) {
+		function testBreakContainer( input, expected ) {
 			const { view, selection } = parse( input );
 
 			const newPosition = writer.breakContainer( selection.getFirstPosition() );
@@ -32,7 +32,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'break inside element - should break container element at given position', () => {
-			test(
+			testBreakContainer(
 				'<container:div>' +
 					'<container:p>' +
 						'<attribute:b>foo</attribute:b>[]<attribute:u>bar</attribute:u>' +
@@ -51,14 +51,14 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'break at start of element - should not break container and place returned position before element', () => {
-			test(
+			testBreakContainer(
 				'<container:div><container:p>[]foobar</container:p></container:div>',
 				'<container:div>[]<container:p>foobar</container:p></container:div>'
 			);
 		} );
 
 		it( 'break at the end of element - should not break container and place returned position after element', () => {
-			test(
+			testBreakContainer(
 				'<container:div><container:p>foobar[]</container:p></container:div>',
 				'<container:div><container:p>foobar</container:p>[]</container:div>'
 			);

+ 13 - 13
packages/ckeditor5-engine/tests/view/downcastwriter/clear.js

@@ -23,7 +23,7 @@ describe( 'DowncastWriter', () => {
 		// @param {Object} elementToRemove
 		// @param {String} input
 		// @param {String} expectedResult
-		function test( elementToRemove, input, expectedResult ) {
+		function testDowncast( elementToRemove, input, expectedResult ) {
 			const { view, selection } = parse( input );
 
 			writer.clear( selection.getFirstRange(), elementToRemove );
@@ -56,7 +56,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove matched element from range', () => {
 			const elementToRemove = new AttributeElement( 'b' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>[b<attribute:b>a</attribute:b>r]</container:p>',
 				'<container:p>br</container:p>'
@@ -66,7 +66,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove matched element from range when range is inside text node', () => {
 			const elementToRemove = new AttributeElement( 'b' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>F{o<attribute:b>o</attribute:b> ba}r</container:p>',
 				'<container:p>Fo bar</container:p>'
@@ -76,7 +76,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove multiple matched elements from range', () => {
 			const elementToRemove = new AttributeElement( 'b' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>[Fo<attribute:b>o</attribute:b> b<attribute:b>a</attribute:b>r]</container:p>',
 				'<container:p>Fo br</container:p>'
@@ -86,7 +86,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove multiple matched elements from range when range is inside text node', () => {
 			const elementToRemove = new AttributeElement( 'b' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>F{o<attribute:b>o</attribute:b> <attribute:b>b</attribute:b>a}r</container:p>',
 				'<container:p>Fo ar</container:p>'
@@ -96,7 +96,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove only matched element', () => {
 			const elementToRemove = new AttributeElement( 'b' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>F{o<attribute:i>o</attribute:i> <attribute:b>b</attribute:b>a}r</container:p>',
 				'<container:p>Fo<attribute:i>o</attribute:i> ar</container:p>'
@@ -106,7 +106,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove part of node when range ends inside this node', () => {
 			const elementToRemove = new AttributeElement( 'b' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>f{oo<attribute:b>ba}r</attribute:b></container:p>',
 				'<container:p>foo<attribute:b>r</attribute:b></container:p>'
@@ -116,7 +116,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove part of node when range starts inside this node', () => {
 			const elementToRemove = new AttributeElement( 'b' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>foo<attribute:b>b{ar</attribute:b>bi}z</container:p>',
 				'<container:p>foo<attribute:b>b</attribute:b>biz</container:p>'
@@ -126,7 +126,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove part of node when range starts and ends inside this node', () => {
 			const elementToRemove = new AttributeElement( 'b' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>foo<attribute:b>b{a}r</attribute:b>biz</container:p>',
 				'<container:p>foo<attribute:b>br</attribute:b>biz</container:p>'
@@ -136,7 +136,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should merge after removing', () => {
 			const elementToRemove = new AttributeElement( 'b' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>' +
 					'<attribute:a>fo{o</attribute:a><attribute:b>a</attribute:b><attribute:a>b}iz</attribute:a>' +
@@ -148,7 +148,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove EmptyElement', () => {
 			const elementToRemove = new EmptyElement( 'img' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>f{oo<empty:img></empty:img>ba}r</container:p>',
 				'<container:p>foobar</container:p>'
@@ -158,7 +158,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove UIElement', () => {
 			const elementToRemove = new UIElement( 'span' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'<container:p>f{oo<ui:span></ui:span>ba}r</container:p>',
 				'<container:p>foobar</container:p>'
@@ -168,7 +168,7 @@ describe( 'DowncastWriter', () => {
 		it( 'should remove ContainerElement', () => {
 			const elementToRemove = new ContainerElement( 'p' );
 
-			test(
+			testDowncast(
 				elementToRemove,
 				'[<container:div>foo</container:div><container:p>bar</container:p><container:div>biz</container:div>]',
 				'<container:div>foo</container:div><container:div>biz</container:div>'

+ 15 - 15
packages/ckeditor5-engine/tests/view/downcastwriter/insert.js

@@ -24,7 +24,7 @@ describe( 'DowncastWriter', () => {
 		// @param {String} input
 		// @param {Array.<String>} nodesToInsert
 		// @param {String} expected
-		function test( input, nodesToInsert, expected ) {
+		function testInsert( input, nodesToInsert, expected ) {
 			nodesToInsert = nodesToInsert.map( node => parse( node ) );
 			const { view, selection } = parse( input );
 
@@ -38,7 +38,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should return collapsed range in insertion position when using empty array', () => {
-			test(
+			testInsert(
 				'<container:p>foo{}bar</container:p>',
 				[],
 				'<container:p>foo{}bar</container:p>'
@@ -46,7 +46,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should insert text into another text node #1', () => {
-			test(
+			testInsert(
 				'<container:p>foo{}bar</container:p>',
 				[ 'baz' ],
 				'<container:p>foo{baz}bar</container:p>'
@@ -54,7 +54,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should insert text into another text node #2', () => {
-			test(
+			testInsert(
 				'<container:p>foobar{}</container:p>',
 				[ 'baz' ],
 				'<container:p>foobar{baz]</container:p>'
@@ -62,7 +62,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should insert text into another text node #3', () => {
-			test(
+			testInsert(
 				'<container:p>{}foobar</container:p>',
 				[ 'baz' ],
 				'<container:p>[baz}foobar</container:p>'
@@ -70,7 +70,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should break attributes when inserting into text node', () => {
-			test(
+			testInsert(
 				'<container:p>foo{}bar</container:p>',
 				[ '<attribute:b view-priority="1">baz</attribute:b>' ],
 				'<container:p>foo[<attribute:b view-priority="1">baz</attribute:b>]bar</container:p>'
@@ -78,7 +78,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge text nodes', () => {
-			test(
+			testInsert(
 				'<container:p>[]foobar</container:p>',
 				[ 'baz' ],
 				'<container:p>[baz}foobar</container:p>'
@@ -86,7 +86,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge same attribute nodes', () => {
-			test(
+			testInsert(
 				'<container:p><attribute:b view-priority="1">foo{}bar</attribute:b></container:p>',
 				[ '<attribute:b view-priority="1">baz</attribute:b>' ],
 				'<container:p><attribute:b view-priority="1">foo{baz}bar</attribute:b></container:p>'
@@ -94,7 +94,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should not merge different attributes', () => {
-			test(
+			testInsert(
 				'<container:p><attribute:b view-priority="1">foo{}bar</attribute:b></container:p>',
 				[ '<attribute:b view-priority="2">baz</attribute:b>' ],
 				'<container:p>' +
@@ -114,7 +114,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should allow to insert multiple nodes', () => {
-			test(
+			testInsert(
 				'<container:p>[]</container:p>',
 				[ '<attribute:b view-priority="1">foo</attribute:b>', 'bar' ],
 				'<container:p>[<attribute:b view-priority="1">foo</attribute:b>bar]</container:p>'
@@ -122,7 +122,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge after inserting multiple nodes', () => {
-			test(
+			testInsert(
 				'<container:p><attribute:b view-priority="1">qux</attribute:b>[]baz</container:p>',
 				[ '<attribute:b view-priority="1">foo</attribute:b>', 'bar' ],
 				'<container:p><attribute:b view-priority="1">qux{foo</attribute:b>bar}baz</container:p>'
@@ -130,7 +130,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should insert text into in document fragment', () => {
-			test(
+			testInsert(
 				'foo{}bar',
 				[ 'baz' ],
 				'foo{baz}bar'
@@ -138,7 +138,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge same attribute nodes in document fragment', () => {
-			test(
+			testInsert(
 				'<attribute:b view-priority="2">foo</attribute:b>[]',
 				[ '<attribute:b view-priority="1">bar</attribute:b>' ],
 				'<attribute:b view-priority="2">foo</attribute:b>[<attribute:b view-priority="1">bar</attribute:b>]'
@@ -146,7 +146,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should insert unicode text into unicode text', () => {
-			test(
+			testInsert(
 				'நி{}க்கு',
 				[ 'லை' ],
 				'நி{லை}க்கு'
@@ -185,7 +185,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should allow to insert EmptyElement into container', () => {
-			test(
+			testInsert(
 				'<container:p>[]</container:p>',
 				[ '<empty:img></empty:img>' ],
 				'<container:p>[<empty:img></empty:img>]</container:p>'

+ 15 - 15
packages/ckeditor5-engine/tests/view/downcastwriter/mergeattributes.js

@@ -19,7 +19,7 @@ describe( 'DowncastWriter', () => {
 		//
 		// @param {String} input
 		// @param {String} expected
-		function test( input, expected ) {
+		function testMerge( input, expected ) {
 			const { view, selection } = parse( input );
 			const newPosition = writer.mergeAttributes( selection.getFirstPosition() );
 			expect( stringify( view, newPosition, { showType: true, showPriority: true } ) ).to.equal( expected );
@@ -30,32 +30,32 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should not merge if inside text node', () => {
-			test( '<container:p>fo{}bar</container:p>', '<container:p>fo{}bar</container:p>' );
+			testMerge( '<container:p>fo{}bar</container:p>', '<container:p>fo{}bar</container:p>' );
 		} );
 
 		it( 'should not merge if between containers', () => {
-			test(
+			testMerge(
 				'<container:div><container:p>foo</container:p>[]<container:p>bar</container:p></container:div>',
 				'<container:div><container:p>foo</container:p>[]<container:p>bar</container:p></container:div>'
 			);
 		} );
 
 		it( 'should return same position when inside empty container', () => {
-			test(
+			testMerge(
 				'<container:p>[]</container:p>',
 				'<container:p>[]</container:p>'
 			);
 		} );
 
 		it( 'should not merge when position is placed at the beginning of the container', () => {
-			test(
+			testMerge(
 				'<container:p>[]<attribute:b view-priority="1"></attribute:b></container:p>',
 				'<container:p>[]<attribute:b view-priority="1"></attribute:b></container:p>'
 			);
 		} );
 
 		it( 'should not merge when position is placed at the end of the container', () => {
-			test(
+			testMerge(
 				'<container:p><attribute:b view-priority="1"></attribute:b>[]</container:p>',
 				'<container:p><attribute:b view-priority="1"></attribute:b>[]</container:p>'
 			);
@@ -73,7 +73,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge when placed between similar attribute nodes', () => {
-			test(
+			testMerge(
 				'<container:p>' +
 					'<attribute:b view-priority="1" foo="bar">baz</attribute:b>[]' +
 					'<attribute:b view-priority="1" foo="bar">qux</attribute:b>' +
@@ -83,7 +83,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should not merge when placed between non-similar attribute nodes', () => {
-			test(
+			testMerge(
 				'<container:p>' +
 					'<attribute:b view-priority="1" foo="bar"></attribute:b>[]<attribute:b view-priority="1" foo="baz"></attribute:b>' +
 				'</container:p>',
@@ -94,7 +94,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should not merge when placed between similar attribute nodes with different priority', () => {
-			test(
+			testMerge(
 				'<container:p>' +
 					'<attribute:b view-priority="1" foo="bar"></attribute:b>[]<attribute:b view-priority="2" foo="bar"></attribute:b>' +
 				'</container:p>',
@@ -105,7 +105,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge attribute nodes and their contents if possible', () => {
-			test(
+			testMerge(
 				'<container:p>' +
 					'<attribute:b view-priority="1" foo="bar">foo</attribute:b>[]' +
 					'<attribute:b view-priority="1" foo="bar">bar</attribute:b>' +
@@ -115,35 +115,35 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should remove empty attributes after merge #1', () => {
-			test(
+			testMerge(
 				'<container:p><attribute:b>[]</attribute:b></container:p>',
 				'<container:p>[]</container:p>'
 			);
 		} );
 
 		it( 'should remove empty attributes after merge #2', () => {
-			test(
+			testMerge(
 				'<container:p><attribute:b>foo</attribute:b><attribute:i>[]</attribute:i><attribute:b>bar</attribute:b></container:p>',
 				'<container:p><attribute:b view-priority="10">foo{}bar</attribute:b></container:p>'
 			);
 		} );
 
 		it( 'should remove empty attributes after merge #3', () => {
-			test(
+			testMerge(
 				'<container:p><attribute:b></attribute:b><attribute:i>[]</attribute:i><attribute:b></attribute:b></container:p>',
 				'<container:p>[]</container:p>'
 			);
 		} );
 
 		it( 'should not merge when placed between EmptyElements', () => {
-			test(
+			testMerge(
 				'<container:p><empty:img></empty:img>[]<empty:img></empty:img></container:p>',
 				'<container:p><empty:img></empty:img>[]<empty:img></empty:img></container:p>'
 			);
 		} );
 
 		it( 'should not merge when placed between UIElements', () => {
-			test(
+			testMerge(
 				'<container:p><ui:span></ui:span>[]<ui:span></ui:span></container:p>',
 				'<container:p><ui:span></ui:span>[]<ui:span></ui:span></container:p>'
 			);

+ 4 - 4
packages/ckeditor5-engine/tests/view/downcastwriter/mergecontainers.js

@@ -18,7 +18,7 @@ describe( 'DowncastWriter', () => {
 		//
 		// @param {String} input
 		// @param {String} expected
-		function test( input, expected ) {
+		function testMerge( input, expected ) {
 			const { view, selection } = parse( input );
 
 			const newPosition = writer.mergeContainers( selection.getFirstPosition() );
@@ -30,7 +30,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge two container elements - position between elements', () => {
-			test(
+			testMerge(
 				'<container:div>' +
 					'<attribute:b>foo</attribute:b>' +
 				'</container:div>' +
@@ -43,14 +43,14 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge two container elements - position in text', () => {
-			test(
+			testMerge(
 				'<container:div>foo</container:div>[]<container:div>bar</container:div>',
 				'<container:div>foo{}bar</container:div>'
 			);
 		} );
 
 		it( 'should merge two different container elements', () => {
-			test(
+			testMerge(
 				'<container:div>foo</container:div>[]<container:p>bar</container:p>',
 				'<container:div>foo{}bar</container:div>'
 			);

+ 11 - 11
packages/ckeditor5-engine/tests/view/downcastwriter/move.js

@@ -27,7 +27,7 @@ describe( 'DowncastWriter', () => {
 		// @param {String} input
 		// @param {String} expectedResult
 		// @param {String} expectedRemoved
-		function test( source, destination, sourceAfterMove, destinationAfterMove ) {
+		function testMove( source, destination, sourceAfterMove, destinationAfterMove ) {
 			const { view: srcView, selection: srcSelection } = parse( source );
 			const { view: dstView, selection: dstSelection } = parse( destination );
 
@@ -42,7 +42,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should move single text node', () => {
-			test(
+			testMove(
 				'<container:p>[foobar]</container:p>',
 				'<container:p>[]</container:p>',
 				'<container:p></container:p>',
@@ -51,7 +51,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should not leave empty text nodes', () => {
-			test(
+			testMove(
 				'<container:p>{foobar}</container:p>',
 				'<container:p>[]</container:p>',
 				'<container:p></container:p>',
@@ -60,7 +60,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should move part of the text node', () => {
-			test(
+			testMove(
 				'<container:p>f{oob}ar</container:p>',
 				'<container:p>[]</container:p>',
 				'<container:p>far</container:p>',
@@ -69,7 +69,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should support unicode', () => {
-			test(
+			testMove(
 				'<container:p>நி{லை}க்கு</container:p>',
 				'<container:p>நி{}கு</container:p>',
 				'<container:p>நிக்கு</container:p>',
@@ -78,7 +78,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should move parts of nodes', () => {
-			test(
+			testMove(
 				'<container:p>f{oo<attribute:b view-priority="10">ba}r</attribute:b></container:p>',
 				'<container:p>[]<attribute:b view-priority="10">qux</attribute:b></container:p>',
 				'<container:p>f<attribute:b view-priority="10">r</attribute:b></container:p>',
@@ -87,7 +87,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge after moving #1', () => {
-			test(
+			testMove(
 				'<container:p>' +
 					'<attribute:b view-priority="1">foo</attribute:b>[bar]<attribute:b view-priority="1">bazqux</attribute:b>' +
 				'</container:p>',
@@ -100,7 +100,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge after moving #2', () => {
-			test(
+			testMove(
 				'<container:p>' +
 					'<attribute:b view-priority="1">fo{o</attribute:b>bar<attribute:b view-priority="1">ba}zqux</attribute:b>' +
 				'</container:p>',
@@ -113,7 +113,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should move part of the text node in document fragment', () => {
-			test( 'fo{ob}ar', 'fo{}ar', 'foar', 'fo{ob}ar' );
+			testMove( 'fo{ob}ar', 'fo{}ar', 'foar', 'fo{ob}ar' );
 		} );
 
 		it( 'should correctly move text nodes inside same parent', () => {
@@ -139,7 +139,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should move EmptyElement', () => {
-			test(
+			testMove(
 				'<container:p>foo[<empty:img></empty:img>]bar</container:p>',
 				'<container:div>baz{}quix</container:div>',
 				'<container:p>foobar</container:p>',
@@ -162,7 +162,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should move UIElement', () => {
-			test(
+			testMove(
 				'<container:p>foo[<ui:span></ui:span>]bar</container:p>',
 				'<container:div>baz{}quix</container:div>',
 				'<container:p>foobar</container:p>',

+ 17 - 17
packages/ckeditor5-engine/tests/view/downcastwriter/remove.js

@@ -26,7 +26,7 @@ describe( 'DowncastWriter', () => {
 		// @param {String} expectedResult
 		// @param {String} expectedRemoved
 		// @param {Boolean} asItem
-		function test( input, expectedResult, expectedRemoved, asItem = false ) {
+		function testRemove( input, expectedResult, expectedRemoved, asItem = false ) {
 			const { view, selection } = parse( input );
 
 			const range = selection.getFirstRange();
@@ -70,19 +70,19 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should remove single text node', () => {
-			test( '<container:p>[foobar]</container:p>', '<container:p>[]</container:p>', 'foobar' );
+			testRemove( '<container:p>[foobar]</container:p>', '<container:p>[]</container:p>', 'foobar' );
 		} );
 
 		it( 'should not leave empty text nodes', () => {
-			test( '<container:p>{foobar}</container:p>', '<container:p>[]</container:p>', 'foobar' );
+			testRemove( '<container:p>{foobar}</container:p>', '<container:p>[]</container:p>', 'foobar' );
 		} );
 
 		it( 'should remove part of the text node', () => {
-			test( '<container:p>f{oob}ar</container:p>', '<container:p>f{}ar</container:p>', 'oob' );
+			testRemove( '<container:p>f{oob}ar</container:p>', '<container:p>f{}ar</container:p>', 'oob' );
 		} );
 
 		it( 'should remove parts of nodes #1', () => {
-			test(
+			testRemove(
 				'<container:p>f{oo<attribute:b view-priority="10">ba}r</attribute:b></container:p>',
 				'<container:p>f[]<attribute:b view-priority="10">r</attribute:b></container:p>',
 				'oo<attribute:b view-priority="10">ba</attribute:b>'
@@ -90,7 +90,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should support unicode', () => {
-			test(
+			testRemove(
 				'<container:p>நி{லை<attribute:b view-priority="10">க்}கு</attribute:b></container:p>',
 				'<container:p>நி[]<attribute:b view-priority="10">கு</attribute:b></container:p>',
 				'லை<attribute:b view-priority="10">க்</attribute:b>'
@@ -98,7 +98,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge after removing #1', () => {
-			test(
+			testRemove(
 				'<container:p>' +
 					'<attribute:b view-priority="1">foo</attribute:b>[bar]<attribute:b view-priority="1">bazqux</attribute:b>' +
 				'</container:p>',
@@ -108,7 +108,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge after removing #2', () => {
-			test(
+			testRemove(
 				'<container:p>' +
 					'<attribute:b view-priority="1">fo{o</attribute:b>bar<attribute:b view-priority="1">ba}zqux</attribute:b>' +
 				'</container:p>',
@@ -118,11 +118,11 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should remove part of the text node in document fragment', () => {
-			test( 'fo{ob}ar', 'fo{}ar', 'ob' );
+			testRemove( 'fo{ob}ar', 'fo{}ar', 'ob' );
 		} );
 
 		it( 'should remove EmptyElement', () => {
-			test(
+			testRemove(
 				'<container:p>foo[<empty:img></empty:img>]bar</container:p>',
 				'<container:p>foo{}bar</container:p>',
 				'<empty:img></empty:img>'
@@ -141,7 +141,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should remove UIElement', () => {
-			test(
+			testRemove(
 				'<container:p>foo[<ui:span></ui:span>]bar</container:p>',
 				'<container:p>foo{}bar</container:p>',
 				'<ui:span></ui:span>'
@@ -160,19 +160,19 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should remove single text node (as item)', () => {
-			test( '<container:p>[foobar]</container:p>', '<container:p></container:p>', 'foobar', true );
+			testRemove( '<container:p>[foobar]</container:p>', '<container:p></container:p>', 'foobar', true );
 		} );
 
 		it( 'should not leave empty text nodes (as item)', () => {
-			test( '<container:p>{foobar}</container:p>', '<container:p></container:p>', 'foobar', true );
+			testRemove( '<container:p>{foobar}</container:p>', '<container:p></container:p>', 'foobar', true );
 		} );
 
 		it( 'should remove part of the text node (as item)', () => {
-			test( '<container:p>f{oob}ar</container:p>', '<container:p>far</container:p>', 'oob', true );
+			testRemove( '<container:p>f{oob}ar</container:p>', '<container:p>far</container:p>', 'oob', true );
 		} );
 
 		it( 'should merge after removing (as item)', () => {
-			test(
+			testRemove(
 				'<container:p>' +
 					'<attribute:b view-priority="1">foo</attribute:b>[bar]<attribute:b view-priority="1">bazqux</attribute:b>' +
 				'</container:p>',
@@ -183,7 +183,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should remove EmptyElement (as item)', () => {
-			test(
+			testRemove(
 				'<container:p>foo[<empty:img></empty:img>]bar</container:p>',
 				'<container:p>foobar</container:p>',
 				'<empty:img></empty:img>',
@@ -192,7 +192,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should remove UIElement (as item)', () => {
-			test(
+			testRemove(
 				'<container:p>foo[<ui:span></ui:span>]bar</container:p>',
 				'<container:p>foobar</container:p>',
 				'<ui:span></ui:span>',

+ 30 - 30
packages/ckeditor5-engine/tests/view/downcastwriter/unwrap.js

@@ -26,7 +26,7 @@ describe( 'DowncastWriter', () => {
 		// @param {String} input
 		// @param {String} unwrapAttribute
 		// @param {String} expected
-		function test( input, unwrapAttribute, expected ) {
+		function testUnwrap( input, unwrapAttribute, expected ) {
 			const { view, selection } = parse( input );
 
 			const newRange = writer.unwrap( selection.getFirstRange(), parse( unwrapAttribute ) );
@@ -39,7 +39,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should do nothing on collapsed ranges', () => {
-			test(
+			testUnwrap(
 				'<container:p>f{}oo</container:p>',
 				'<attribute:b view-priority="10"></attribute:b>',
 				'<container:p>f{}oo</container:p>'
@@ -47,7 +47,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should do nothing on single text node', () => {
-			test(
+			testUnwrap(
 				'<container:p>[foobar]</container:p>',
 				'<attribute:b view-priority="1"></attribute:b>',
 				'<container:p>[foobar]</container:p>'
@@ -91,7 +91,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should unwrap single node', () => {
-			test(
+			testUnwrap(
 				'<container:p>[<attribute:b view-priority="1">foobar</attribute:b>]</container:p>',
 				'<attribute:b view-priority="1"></attribute:b>',
 				'<container:p>[foobar]</container:p>'
@@ -99,7 +99,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should not unwrap attributes with different priorities #1', () => {
-			test(
+			testUnwrap(
 				'<container:p>[<attribute:b view-priority="1">foobar</attribute:b>]</container:p>',
 				'<attribute:b view-priority="2"></attribute:b>',
 				'<container:p>[<attribute:b view-priority="1">foobar</attribute:b>]</container:p>'
@@ -107,7 +107,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should not unwrap attributes with different priorities #2', () => {
-			test(
+			testUnwrap(
 				'<container:p>' +
 				'[' +
 					'<attribute:b view-priority="2">foo</attribute:b>' +
@@ -121,7 +121,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should unwrap part of the node', () => {
-			test(
+			testUnwrap(
 				'<container:p>[baz<attribute:b view-priority="1">foo}bar</attribute:b></container:p>',
 				'<attribute:b view-priority="1"></attribute:b>',
 				'<container:p>[bazfoo]<attribute:b view-priority="1">bar</attribute:b></container:p>'
@@ -129,7 +129,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should support unicode', () => {
-			test(
+			testUnwrap(
 				'<container:p>[நிலை<attribute:b view-priority="1">க்}கு</attribute:b></container:p>',
 				'<attribute:b view-priority="1"></attribute:b>',
 				'<container:p>[நிலைக்]<attribute:b view-priority="1">கு</attribute:b></container:p>'
@@ -137,7 +137,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should unwrap nested attributes', () => {
-			test(
+			testUnwrap(
 				'<container:p>' +
 					'[<attribute:u view-priority="1"><attribute:b view-priority="1">foobar</attribute:b></attribute:u>]' +
 				'</container:p>',
@@ -147,7 +147,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should unwrap a part of a nested attribute', () => {
-			test(
+			testUnwrap(
 				'<container:p>' +
 					'<attribute:u view-priority="1"><attribute:b view-priority="1">fo{ob}ar</attribute:b></attribute:u>' +
 				'</container:p>',
@@ -163,7 +163,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should merge unwrapped nodes #1', () => {
-			test(
+			testUnwrap(
 				'<container:p>foo[<attribute:b view-priority="1">bar</attribute:b>]baz</container:p>',
 				'<attribute:b view-priority="1"></attribute:b>',
 				'<container:p>foo{bar}baz</container:p>'
@@ -183,7 +183,7 @@ describe( 'DowncastWriter', () => {
 			const attribute = '<attribute:b view-priority="1"></attribute:b>';
 			const result = '<container:p>foo<attribute:u view-priority="1">bar{bazqux</attribute:u>]</container:p>';
 
-			test( input, attribute, result );
+			testUnwrap( input, attribute, result );
 		} );
 
 		it( 'should merge unwrapped nodes #3', () => {
@@ -204,7 +204,7 @@ describe( 'DowncastWriter', () => {
 				'</attribute:b>' +
 			'</container:p>';
 
-			test( input, attribute, result );
+			testUnwrap( input, attribute, result );
 		} );
 
 		it( 'should merge unwrapped nodes #4', () => {
@@ -224,7 +224,7 @@ describe( 'DowncastWriter', () => {
 				'<attribute:u view-priority="1">bar{baz}qux</attribute:u>' +
 			'</container:p>';
 
-			test( input, attribute, result );
+			testUnwrap( input, attribute, result );
 		} );
 
 		it( 'should merge unwrapped nodes #5', () => {
@@ -238,7 +238,7 @@ describe( 'DowncastWriter', () => {
 			const attribute = '<attribute:b view-priority="1"></attribute:b>';
 			const result = '<container:p>[<attribute:u view-priority="1">foobarbaz</attribute:u>]</container:p>';
 
-			test( input, attribute, result );
+			testUnwrap( input, attribute, result );
 		} );
 
 		it( 'should unwrap mixed ranges #1', () => {
@@ -251,11 +251,11 @@ describe( 'DowncastWriter', () => {
 			const attribute = '<attribute:b view-priority="1"></attribute:b>';
 			const result = '<container:p>[<attribute:u view-priority="1">foo</attribute:u>]</container:p>';
 
-			test( input, attribute, result );
+			testUnwrap( input, attribute, result );
 		} );
 
 		it( 'should unwrap mixed ranges #2', () => {
-			test(
+			testUnwrap(
 				'<container:p>' +
 					'[<attribute:u view-priority="1"><attribute:b view-priority="1">foo}</attribute:b></attribute:u>' +
 				'</container:p>',
@@ -265,7 +265,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should unwrap single element by removing matching attributes', () => {
-			test(
+			testUnwrap(
 				'<container:p>[<attribute:b view-priority="1" foo="bar" baz="qux">test</attribute:b>]</container:p>',
 				'<attribute:b view-priority="1" baz="qux"></attribute:b>',
 				'<container:p>[<attribute:b view-priority="1" foo="bar">test</attribute:b>]</container:p>'
@@ -273,7 +273,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should not unwrap single element when attributes are different', () => {
-			test(
+			testUnwrap(
 				'<container:p>[<attribute:b view-priority="1" baz="qux" foo="bar">test</attribute:b>]</container:p>',
 				'<attribute:b view-priority="1" baz="qux" test="true"></attribute:b>',
 				'<container:p>[<attribute:b view-priority="1" baz="qux" foo="bar">test</attribute:b>]</container:p>'
@@ -281,7 +281,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should unwrap single element by removing matching classes', () => {
-			test(
+			testUnwrap(
 				'<container:p>[<attribute:b view-priority="1" class="bar baz foo">test</attribute:b>]</container:p>',
 				'<attribute:b view-priority="1" class="baz foo"></attribute:b>',
 				'<container:p>[<attribute:b view-priority="1" class="bar">test</attribute:b>]</container:p>'
@@ -289,7 +289,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should not unwrap single element when classes are different', () => {
-			test(
+			testUnwrap(
 				'<container:p>[<attribute:b view-priority="1" class="bar baz foo">test</attribute:b>]</container:p>',
 				'<attribute:b view-priority="1" class="baz foo qux"></attribute:b>',
 				'<container:p>[<attribute:b view-priority="1" class="bar baz foo">test</attribute:b>]</container:p>'
@@ -297,7 +297,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should unwrap single element by removing matching styles', () => {
-			test(
+			testUnwrap(
 				'<container:p>' +
 					'[<attribute:b view-priority="1" style="color:red;position:absolute;top:10px;">test</attribute:b>]' +
 				'</container:p>',
@@ -307,7 +307,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should not unwrap single element when styles are different', () => {
-			test(
+			testUnwrap(
 				'<container:p>' +
 					'[<attribute:b view-priority="1" style="color:red;position:absolute;top:10px">test</attribute:b>]' +
 				'</container:p>',
@@ -319,7 +319,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should partially unwrap part of a node', () => {
-			test(
+			testUnwrap(
 				'<container:p>' +
 					'[<attribute:b view-priority="1" baz="qux" foo="bar">foo}bar</attribute:b>' +
 				'</container:p>',
@@ -332,7 +332,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should partially unwrap a nested attribute', () => {
-			test(
+			testUnwrap(
 				'<container:p>' +
 					'[<attribute:i view-priority="1">' +
 						'<attribute:b view-priority="1" style="color:red;position:absolute;top:10px;">test</attribute:b>' +
@@ -348,7 +348,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should partially unwrap a part of a nested attribute', () => {
-			test(
+			testUnwrap(
 				'<container:p>' +
 					'<attribute:i view-priority="1">' +
 						'<attribute:b view-priority="1" style="color:red;position:absolute;top:10px;">t{es}t</attribute:b>' +
@@ -366,7 +366,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should be merged after being partially unwrapped', () => {
-			test(
+			testUnwrap(
 				'<container:p>' +
 					'<attribute:b view-priority="1" baz="qux">xyz</attribute:b>' +
 					'[<attribute:b view-priority="1" baz="qux" foo="bar">foo}bar</attribute:b>' +
@@ -380,7 +380,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should unwrap single node in document fragment', () => {
-			test(
+			testUnwrap(
 				'<container:p>[<attribute:b view-priority="1">foobar</attribute:b>]</container:p>',
 				'<attribute:b view-priority="1"></attribute:b>',
 				'<container:p>[foobar]</container:p>'
@@ -388,7 +388,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should unwrap EmptyElement', () => {
-			test(
+			testUnwrap(
 				'<container:p>[<attribute:b><empty:img></empty:img></attribute:b>]</container:p>',
 				'<attribute:b></attribute:b>',
 				'<container:p>[<empty:img></empty:img>]</container:p>'
@@ -407,7 +407,7 @@ describe( 'DowncastWriter', () => {
 		} );
 
 		it( 'should unwrap UIElement', () => {
-			test(
+			testUnwrap(
 				'<container:p>[<attribute:b><ui:span></ui:span></attribute:b>]</container:p>',
 				'<attribute:b></attribute:b>',
 				'<container:p>[<ui:span></ui:span>]</container:p>'

+ 46 - 46
packages/ckeditor5-engine/tests/view/downcastwriter/wrap.js

@@ -37,7 +37,7 @@ describe( 'DowncastWriter', () => {
 			 * @param {String} wrapAttribute
 			 * @param {String} expected
 			 */
-			function test( input, wrapAttribute, expected ) {
+			function testWrap( input, wrapAttribute, expected ) {
 				const { view, selection } = parse( input );
 				const newRange = writer.wrap( selection.getFirstRange(), parse( wrapAttribute ) );
 
@@ -46,7 +46,7 @@ describe( 'DowncastWriter', () => {
 			}
 
 			it( 'wraps single text node', () => {
-				test(
+				testWrap(
 					'<container:p>[foobar]</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p>[<attribute:b view-priority="1">foobar</attribute:b>]</container:p>'
@@ -54,7 +54,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'wraps single text node in document fragment', () => {
-				test(
+				testWrap(
 					'{foobar}',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'[<attribute:b view-priority="1">foobar</attribute:b>]'
@@ -98,7 +98,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'wraps part of a single text node #1', () => {
-				test(
+				testWrap(
 					'<container:p>[foo}bar</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p>[<attribute:b view-priority="1">foo</attribute:b>]bar</container:p>'
@@ -106,7 +106,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'wraps part of a single text node #2', () => {
-				test(
+				testWrap(
 					'<container:p>{foo}bar</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p>[<attribute:b view-priority="1">foo</attribute:b>]bar</container:p>'
@@ -114,7 +114,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should support unicode', () => {
-				test(
+				testWrap(
 					'<container:p>நி{லை}க்கு</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p>நி[<attribute:b view-priority="1">லை</attribute:b>]க்கு</container:p>'
@@ -122,7 +122,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should join wrapping element with a nested attribute element', () => {
-				test(
+				testWrap(
 					'<container:p>' +
 						'<attribute:u view-priority="1">' +
 							'<attribute:b view-priority="2" class="bar">{foo}</attribute:b>' +
@@ -140,7 +140,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should join wrapping element with a part of a nested attribute element', () => {
-				test(
+				testWrap(
 					'<container:p>' +
 						'<attribute:i view-priority="1">' +
 							'<attribute:b view-priority="2" class="bar">fo{ob}ar</attribute:b>' +
@@ -160,7 +160,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'wraps part of a single text node #3', () => {
-				test(
+				testWrap(
 					'<container:p>foo{bar}</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p>foo[<attribute:b view-priority="1">bar</attribute:b>]</container:p>'
@@ -168,7 +168,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should not wrap inside nested containers', () => {
-				test(
+				testWrap(
 					'<container:div>[foobar<container:p>baz</container:p>]</container:div>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:div>[<attribute:b view-priority="1">foobar</attribute:b><container:p>baz</container:p>]</container:div>'
@@ -176,7 +176,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'wraps according to priorities', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:u view-priority="1">foobar</attribute:u>]</container:p>',
 
 					'<attribute:b view-priority="2"></attribute:b>',
@@ -188,7 +188,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'merges wrapped nodes #1', () => {
-				test(
+				testWrap(
 					'<container:p>' +
 						'[<attribute:b view-priority="1">foo</attribute:b>bar<attribute:b view-priority="1">baz</attribute:b>]' +
 					'</container:p>',
@@ -200,7 +200,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'merges wrapped nodes #2', () => {
-				test(
+				testWrap(
 					'<container:p><attribute:b view-priority="1">foo</attribute:b>[bar}baz</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p><attribute:b view-priority="1">foo{bar</attribute:b>]baz</container:p>'
@@ -208,7 +208,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'merges wrapped nodes #3', () => {
-				test(
+				testWrap(
 					'<container:p><attribute:b view-priority="1">foobar</attribute:b>[baz]</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p><attribute:b view-priority="1">foobar{baz</attribute:b>]</container:p>'
@@ -216,7 +216,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'merges wrapped nodes #4', () => {
-				test(
+				testWrap(
 					'<container:p>[foo<attribute:i view-priority="1">bar</attribute:i>]baz</container:p>',
 
 					'<attribute:b view-priority="1"></attribute:b>',
@@ -228,7 +228,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'merges wrapped nodes #5', () => {
-				test(
+				testWrap(
 					'<container:p>[foo<attribute:i view-priority="1">bar</attribute:i>baz]</container:p>',
 
 					'<attribute:b view-priority="2"></attribute:b>',
@@ -246,7 +246,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'merges wrapped nodes #6', () => {
-				test(
+				testWrap(
 					'<container:div>f{o<attribute:strong>ob</attribute:strong>a}r</container:div>',
 
 					'<attribute:span view-priority="1"></attribute:span>',
@@ -260,7 +260,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should wrap single element by merging attributes', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:b view-priority="1" foo="bar" one="two"></attribute:b>]</container:p>',
 					'<attribute:b view-priority="1" baz="qux" one="two"></attribute:b>',
 					'<container:p>[<attribute:b view-priority="1" baz="qux" foo="bar" one="two"></attribute:b>]</container:p>'
@@ -268,7 +268,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should not merge attributes when they differ', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:b view-priority="1" foo="bar">text</attribute:b>]</container:p>',
 
 					'<attribute:b view-priority="1" foo="baz"></attribute:b>',
@@ -282,7 +282,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should wrap single element by merging classes', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:b view-priority="1" class="foo bar baz"></attribute:b>]</container:p>',
 					'<attribute:b view-priority="1" class="foo bar qux jax"></attribute:b>',
 					'<container:p>[<attribute:b view-priority="1" class="bar baz foo jax qux"></attribute:b>]</container:p>'
@@ -290,7 +290,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should wrap single element by merging styles', () => {
-				test(
+				testWrap(
 					'<container:p>' +
 						'[<attribute:b view-priority="1" style="color:red; position: absolute"></attribute:b>]' +
 					'</container:p>',
@@ -304,7 +304,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should not merge styles when they differ', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:b view-priority="1" style="color:red"></attribute:b>]</container:p>',
 
 					'<attribute:b view-priority="1" style="color:black"></attribute:b>',
@@ -320,7 +320,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should not merge single elements when they have different priority', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:b view-priority="2" style="color:red"></attribute:b>]</container:p>',
 
 					'<attribute:b view-priority="1" style="color:red"></attribute:b>',
@@ -336,7 +336,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should be merged with outside element when wrapping all children', () => {
-				test(
+				testWrap(
 					'<container:p>' +
 						'<attribute:b view-priority="1" foo="bar">[foobar<attribute:i view-priority="1">baz</attribute:i>]</attribute:b>' +
 					'</container:p>',
@@ -355,7 +355,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should be merged with broken element', () => {
-				test(
+				testWrap(
 					'<container:p>' +
 						'[<attribute:b view-priority="1" foo="bar">foo}bar</attribute:b>' +
 					'</container:p>',
@@ -370,7 +370,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should be merged with broken element and merged with siblings', () => {
-				test(
+				testWrap(
 					'<container:p>' +
 						'<attribute:b view-priority="1" baz="qux" foo="bar">xyz</attribute:b>' +
 						'[<attribute:b view-priority="1" foo="bar">foo}bar</attribute:b>' +
@@ -386,7 +386,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should wrap EmptyElement', () => {
-				test(
+				testWrap(
 					'<container:p>[<empty:img></empty:img>]</container:p>',
 					'<attribute:b></attribute:b>',
 					'<container:p>[<attribute:b view-priority="10"><empty:img></empty:img></attribute:b>]</container:p>'
@@ -404,7 +404,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should wrap UIElement', () => {
-				test(
+				testWrap(
 					'<container:p>[<ui:span></ui:span>]</container:p>',
 					'<attribute:b></attribute:b>',
 					'<container:p>[<attribute:b view-priority="10"><ui:span></ui:span></attribute:b>]</container:p>'
@@ -422,7 +422,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should keep stable hierarchy when wrapping with attribute with same priority', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:span>foo</attribute:span>]</container:p>',
 
 					'<attribute:b></attribute:b>',
@@ -434,7 +434,7 @@ describe( 'DowncastWriter', () => {
 					'</container:p>'
 				);
 
-				test(
+				testWrap(
 					'<container:p>[<attribute:b>foo</attribute:b>]</container:p>',
 
 					'<attribute:span></attribute:span>',
@@ -448,7 +448,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should keep stable hierarchy when wrapping with attribute with same priority that can\'t be merged', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:span name="foo">foo</attribute:span>]</container:p>',
 
 					'<attribute:span name="bar"></attribute:span>',
@@ -460,7 +460,7 @@ describe( 'DowncastWriter', () => {
 					'</container:p>'
 				);
 
-				test(
+				testWrap(
 					'<container:p>[<attribute:span name="bar">foo</attribute:span>]</container:p>',
 
 					'<attribute:span name="foo"></attribute:span>',
@@ -474,7 +474,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should not join elements if element to wrap has id', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:span foo="foo" view-id="foo">xyz</attribute:span>]</container:p>',
 
 					'<attribute:span bar="bar"></attribute:span>',
@@ -488,7 +488,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should not join elements if wrapper element has id', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:span foo="foo">xyz</attribute:span>]</container:p>',
 
 					'<attribute:span bar="bar" view-id="foo"></attribute:span>',
@@ -502,7 +502,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should not join elements if they have different ids', () => {
-				test(
+				testWrap(
 					'<container:p>[<attribute:span foo="foo" view-id="foo">xyz</attribute:span>]</container:p>',
 
 					'<attribute:span bar="bar" view-id="bar"></attribute:span>',
@@ -536,7 +536,7 @@ describe( 'DowncastWriter', () => {
 			 * @param {String} wrapAttribute
 			 * @param {String} expected
 			 */
-			function test( input, wrapAttribute, expected ) {
+			function testWrap( input, wrapAttribute, expected ) {
 				const { view, selection } = parse( input, { rootElement: viewRoot } );
 				viewDocument.selection._setTo( selection );
 
@@ -559,7 +559,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should wrap position at the beginning of text node', () => {
-				test(
+				testWrap(
 					'<container:p>{}foobar</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p><attribute:b view-priority="1">[]</attribute:b>foobar</container:p>'
@@ -567,7 +567,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should wrap position inside text node', () => {
-				test(
+				testWrap(
 					'<container:p>foo{}bar</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p>foo<attribute:b view-priority="1">[]</attribute:b>bar</container:p>'
@@ -575,7 +575,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should support unicode', () => {
-				test(
+				testWrap(
 					'<container:p>நிலை{}க்கு</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p>நிலை<attribute:b view-priority="1">[]</attribute:b>க்கு</container:p>'
@@ -583,7 +583,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should wrap position inside document fragment', () => {
-				test(
+				testWrap(
 					'<attribute:b view-priority="1">foo</attribute:b>[]<attribute:b view-priority="3">bar</attribute:b>',
 
 					'<attribute:b view-priority="2"></attribute:b>',
@@ -595,7 +595,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should wrap position at the end of text node', () => {
-				test(
+				testWrap(
 					'<container:p>foobar{}</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p>foobar<attribute:b view-priority="1">[]</attribute:b></container:p>'
@@ -603,7 +603,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should merge with existing attributes #1', () => {
-				test(
+				testWrap(
 					'<container:p><attribute:b view-priority="1">foo</attribute:b>[]</container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p><attribute:b view-priority="1">foo{}</attribute:b></container:p>'
@@ -611,7 +611,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should merge with existing attributes #2', () => {
-				test(
+				testWrap(
 					'<container:p>[]<attribute:b view-priority="1">foo</attribute:b></container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p><attribute:b view-priority="1">{}foo</attribute:b></container:p>'
@@ -619,7 +619,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should wrap when inside nested attributes', () => {
-				test(
+				testWrap(
 					'<container:p><attribute:b view-priority="1">foo{}bar</attribute:b></container:p>',
 
 					'<attribute:u view-priority="1"></attribute:u>',
@@ -635,7 +635,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should merge when wrapping between same attribute', () => {
-				test(
+				testWrap(
 					'<container:p>' +
 						'<attribute:b view-priority="1">foo</attribute:b>[]<attribute:b view-priority="1">bar</attribute:b>' +
 					'</container:p>',
@@ -647,7 +647,7 @@ describe( 'DowncastWriter', () => {
 			} );
 
 			it( 'should move position to text node if in same attribute', () => {
-				test(
+				testWrap(
 					'<container:p><attribute:b view-priority="1">foobar[]</attribute:b></container:p>',
 					'<attribute:b view-priority="1"></attribute:b>',
 					'<container:p><attribute:b view-priority="1">foobar{}</attribute:b></container:p>'

+ 6 - 6
packages/ckeditor5-engine/tests/view/position.js

@@ -598,28 +598,28 @@ describe( 'Position', () => {
 			const afterLoremPosition = new Position( liOl1, 5 );
 			const otherPosition = Position._createAt( afterLoremPosition );
 
-			test( afterLoremPosition, otherPosition, liOl1 );
+			testParent( afterLoremPosition, otherPosition, liOl1 );
 		} );
 
 		it( 'for two positions in the same element returns the element', () => {
 			const startMaecenasPosition = Position._createAt( liOl2, 0 );
 			const beforeTellusPosition = new Position( liOl2, 18 );
 
-			test( startMaecenasPosition, beforeTellusPosition, liOl2 );
+			testParent( startMaecenasPosition, beforeTellusPosition, liOl2 );
 		} );
 
 		it( 'works when one of the positions is nested deeper than the other #1', () => {
 			const firstPosition = new Position( liUl1, 1 );
 			const secondPosition = new Position( p, 3 );
 
-			test( firstPosition, secondPosition, div );
+			testParent( firstPosition, secondPosition, div );
 		} );
 
 		it( 'works when one of the positions is nested deeper than the other #2', () => {
 			const firstPosition = new Position( liOl2, 10 );
 			const secondPosition = new Position( section, 1 );
 
-			test( firstPosition, secondPosition, section );
+			testParent( firstPosition, secondPosition, section );
 		} );
 
 		it( 'for two positions in different trees returns null', () => {
@@ -627,10 +627,10 @@ describe( 'Position', () => {
 			const posInDiv = new Position( div, 0 );
 			const firstPosition = new Position( liOl2, 10 );
 
-			test( posInDiv, firstPosition, null );
+			testParent( posInDiv, firstPosition, null );
 		} );
 
-		function test( positionA, positionB, lca ) {
+		function testParent( positionA, positionB, lca ) {
 			expect( positionA.getCommonAncestor( positionB ) ).to.equal( lca );
 			expect( positionB.getCommonAncestor( positionA ) ).to.equal( lca );
 		}