8
0
Просмотр исходного кода

Merge branch t/ckeditor5-engine/858

Internal: Update API usage after merge t/858 on engine.
Piotr Jasiun 8 лет назад
Родитель
Сommit
6d23f5ed2a
2 измененных файлов с 35 добавлено и 33 удалено
  1. 1 2
      packages/ckeditor5-paragraph/src/paragraph.js
  2. 34 31
      packages/ckeditor5-paragraph/tests/paragraph.js

+ 1 - 2
packages/ckeditor5-paragraph/src/paragraph.js

@@ -11,7 +11,6 @@ import ParagraphCommand from './paragraphcommand';
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 import Plugin from '@ckeditor/ckeditor5-core/src/plugin';
 
 
 import ModelElement from '@ckeditor/ckeditor5-engine/src/model/element';
 import ModelElement from '@ckeditor/ckeditor5-engine/src/model/element';
-import ModelPosition from '@ckeditor/ckeditor5-engine/src/model/position';
 
 
 import buildModelConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildmodelconverter';
 import buildModelConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildmodelconverter';
 import buildViewConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildviewconverter';
 import buildViewConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildviewconverter';
@@ -295,7 +294,7 @@ function autoparagraphEmptyRoots() {
 				rootsToFix.delete( root );
 				rootsToFix.delete( root );
 
 
 				// Fix empty root.
 				// Fix empty root.
-				batch.insert( ModelPosition.createAt( root ), new ModelElement( 'paragraph' ) );
+				batch.insertElement( 'paragraph', root );
 			} );
 			} );
 		}
 		}
 	}
 	}

+ 34 - 31
packages/ckeditor5-paragraph/tests/paragraph.js

@@ -17,13 +17,11 @@ import buildModelConverter from '@ckeditor/ckeditor5-engine/src/conversion/build
 import buildViewConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildviewconverter';
 import buildViewConverter from '@ckeditor/ckeditor5-engine/src/conversion/buildviewconverter';
 
 
 import ModelDocumentFragment from '@ckeditor/ckeditor5-engine/src/model/documentfragment';
 import ModelDocumentFragment from '@ckeditor/ckeditor5-engine/src/model/documentfragment';
-import ModelElement from '@ckeditor/ckeditor5-engine/src/model/element';
 import ModelText from '@ckeditor/ckeditor5-engine/src/model/text';
 import ModelText from '@ckeditor/ckeditor5-engine/src/model/text';
-import ModelPosition from '@ckeditor/ckeditor5-engine/src/model/position';
 import ModelRange from '@ckeditor/ckeditor5-engine/src/model/range';
 import ModelRange from '@ckeditor/ckeditor5-engine/src/model/range';
 
 
 describe( 'Paragraph feature', () => {
 describe( 'Paragraph feature', () => {
-	let editor, doc, root;
+	let editor, doc, root, batch;
 
 
 	beforeEach( () => {
 	beforeEach( () => {
 		return VirtualTestEditor
 		return VirtualTestEditor
@@ -32,6 +30,7 @@ describe( 'Paragraph feature', () => {
 				editor = newEditor;
 				editor = newEditor;
 				doc = editor.document;
 				doc = editor.document;
 				root = doc.getRoot();
 				root = doc.getRoot();
+				batch = doc.batch();
 			} );
 			} );
 	} );
 	} );
 
 
@@ -93,7 +92,7 @@ describe( 'Paragraph feature', () => {
 			} );
 			} );
 
 
 			it( 'should not autoparagraph text (in clipboard holder)', () => {
 			it( 'should not autoparagraph text (in clipboard holder)', () => {
-				const modelFragment = editor.data.parse( 'foo', '$clipboardHolder' );
+				const modelFragment = editor.data.parse( 'foo', batch, '$clipboardHolder' );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( 'foo' );
 					.to.equal( 'foo' );
@@ -102,7 +101,7 @@ describe( 'Paragraph feature', () => {
 			it( 'should not autoparagraph text (in a context which does not allow paragraphs', () => {
 			it( 'should not autoparagraph text (in a context which does not allow paragraphs', () => {
 				doc.schema.registerItem( 'specialRoot' );
 				doc.schema.registerItem( 'specialRoot' );
 
 
-				const modelFragment = editor.data.parse( 'foo', 'specialRoot' );
+				const modelFragment = editor.data.parse( 'foo', batch, 'specialRoot' );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '' );
 					.to.equal( '' );
@@ -112,21 +111,21 @@ describe( 'Paragraph feature', () => {
 				doc.schema.registerItem( 'heading1', '$block' );
 				doc.schema.registerItem( 'heading1', '$block' );
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
 
 
-				const modelFragment = editor.data.parse( '<h1>foo</h1>bar<p>bom</p>' );
+				const modelFragment = editor.data.parse( '<h1>foo</h1>bar<p>bom</p>', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<heading1>foo</heading1><paragraph>bar</paragraph><paragraph>bom</paragraph>' );
 					.to.equal( '<heading1>foo</heading1><paragraph>bar</paragraph><paragraph>bom</paragraph>' );
 			} );
 			} );
 
 
 			it( 'should autoparagraph 3 inline nodes into one paragraph', () => {
 			it( 'should autoparagraph 3 inline nodes into one paragraph', () => {
-				const modelFragment = editor.data.parse( 'foo<b>bar</b>bom' );
+				const modelFragment = editor.data.parse( 'foo<b>bar</b>bom', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<paragraph>foobarbom</paragraph>' );
 					.to.equal( '<paragraph>foobarbom</paragraph>' );
 			} );
 			} );
 
 
 			it( 'should not autoparagraph 3 inline nodes (in clipboardHolder)', () => {
 			it( 'should not autoparagraph 3 inline nodes (in clipboardHolder)', () => {
-				const modelFragment = editor.data.parse( 'foo<b>bar</b>bom', '$clipboardHolder' );
+				const modelFragment = editor.data.parse( 'foo<b>bar</b>bom', batch, '$clipboardHolder' );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( 'foobarbom' );
 					.to.equal( 'foobarbom' );
@@ -139,7 +138,7 @@ describe( 'Paragraph feature', () => {
 
 
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
 
 
-				const modelFragment = editor.data.parse( '<div>foo</div><div>bom<p>bim</p></div>' );
+				const modelFragment = editor.data.parse( '<div>foo</div><div>bom<p>bim</p></div>', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal(
 					.to.equal(
@@ -152,7 +151,7 @@ describe( 'Paragraph feature', () => {
 				doc.schema.registerItem( 'heading1', '$block' );
 				doc.schema.registerItem( 'heading1', '$block' );
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
 
 
-				const modelFragment = editor.data.parse( '<div><h1>foo</h1>bar</div>' );
+				const modelFragment = editor.data.parse( '<div><h1>foo</h1>bar</div>', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<heading1>foo</heading1><paragraph>bar</paragraph>' );
 					.to.equal( '<heading1>foo</heading1><paragraph>bar</paragraph>' );
@@ -162,7 +161,7 @@ describe( 'Paragraph feature', () => {
 				doc.schema.registerItem( 'heading1', '$block' );
 				doc.schema.registerItem( 'heading1', '$block' );
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'h1' ).toElement( 'heading1' );
 
 
-				const modelFragment = editor.data.parse( '<h1><b>foo</b>bar</h1>' );
+				const modelFragment = editor.data.parse( '<h1><b>foo</b>bar</h1>', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<heading1>foobar</heading1>' );
 					.to.equal( '<heading1>foobar</heading1>' );
@@ -171,13 +170,13 @@ describe( 'Paragraph feature', () => {
 			it( 'should not fail when text is not allowed in paragraph', () => {
 			it( 'should not fail when text is not allowed in paragraph', () => {
 				doc.schema.disallow( { name: '$text', inside: [ '$root', 'paragraph' ] } );
 				doc.schema.disallow( { name: '$text', inside: [ '$root', 'paragraph' ] } );
 
 
-				const modelFragment = editor.data.parse( 'foo' );
+				const modelFragment = editor.data.parse( 'foo', batch );
 
 
 				expect( stringifyModel( modelFragment ) ).to.equal( '' );
 				expect( stringifyModel( modelFragment ) ).to.equal( '' );
 			} );
 			} );
 
 
 			it( 'creates normalized model', () => {
 			it( 'creates normalized model', () => {
-				const modelFragment = editor.data.parse( 'foo<b>bar</b>bom' );
+				const modelFragment = editor.data.parse( 'foo<b>bar</b>bom', batch );
 
 
 				expect( modelFragment ).to.be.instanceof( ModelDocumentFragment );
 				expect( modelFragment ).to.be.instanceof( ModelDocumentFragment );
 				expect( modelFragment.getChild( 0 ).childCount ).to.equal( 1 );
 				expect( modelFragment.getChild( 0 ).childCount ).to.equal( 1 );
@@ -190,7 +189,7 @@ describe( 'Paragraph feature', () => {
 					consumable.consume( data.input, { name: true } );
 					consumable.consume( data.input, { name: true } );
 				}, { priority: 'highest' } );
 				}, { priority: 'highest' } );
 
 
-				const modelFragment = editor.data.parse( '<ul><li></li></ul>' );
+				const modelFragment = editor.data.parse( '<ul><li></li></ul>', batch );
 
 
 				expect( stringifyModel( modelFragment ) ).to.equal( '' );
 				expect( stringifyModel( modelFragment ) ).to.equal( '' );
 			} );
 			} );
@@ -204,7 +203,7 @@ describe( 'Paragraph feature', () => {
 				} );
 				} );
 
 
 				it( 'inside document fragment', () => {
 				it( 'inside document fragment', () => {
-					const modelFragment = editor.data.parse( 'foo<b>bar</b>bom' );
+					const modelFragment = editor.data.parse( 'foo<b>bar</b>bom', batch );
 
 
 					expect( stringifyModel( modelFragment ) ).to.equal( '<paragraph>foo<$text bold="true">bar</$text>bom</paragraph>' );
 					expect( stringifyModel( modelFragment ) ).to.equal( '<paragraph>foo<$text bold="true">bar</$text>bom</paragraph>' );
 				} );
 				} );
@@ -220,14 +219,14 @@ describe( 'Paragraph feature', () => {
 
 
 					buildViewConverter().for( editor.data.viewToModel ).fromElement( 'blockquote' ).toElement( 'blockquote' );
 					buildViewConverter().for( editor.data.viewToModel ).fromElement( 'blockquote' ).toElement( 'blockquote' );
 
 
-					const modelFragment = editor.data.parse( '<blockquote>foo<b>bar</b>bom</blockquote>' );
+					const modelFragment = editor.data.parse( '<blockquote>foo<b>bar</b>bom</blockquote>', batch );
 
 
 					expect( stringifyModel( modelFragment ) )
 					expect( stringifyModel( modelFragment ) )
 						.to.equal( '<blockquote><paragraph>foo<$text bold="true">bar</$text>bom</paragraph></blockquote>' );
 						.to.equal( '<blockquote><paragraph>foo<$text bold="true">bar</$text>bom</paragraph></blockquote>' );
 				} );
 				} );
 
 
 				it( 'inside paragraph-like element', () => {
 				it( 'inside paragraph-like element', () => {
-					const modelFragment = editor.data.parse( '<h1>foo</h1><h2><b>bar</b>bom</h2>' );
+					const modelFragment = editor.data.parse( '<h1>foo</h1><h2><b>bar</b>bom</h2>', batch );
 
 
 					expect( stringifyModel( modelFragment ) )
 					expect( stringifyModel( modelFragment ) )
 						.to.equal( '<paragraph>foo</paragraph><paragraph><$text bold="true">bar</$text>bom</paragraph>' );
 						.to.equal( '<paragraph>foo</paragraph><paragraph><$text bold="true">bar</$text>bom</paragraph>' );
@@ -237,14 +236,14 @@ describe( 'Paragraph feature', () => {
 
 
 		describe( 'generic block converter (paragraph-like element handling)', () => {
 		describe( 'generic block converter (paragraph-like element handling)', () => {
 			it( 'should convert h1+h2', () => {
 			it( 'should convert h1+h2', () => {
-				const modelFragment = editor.data.parse( '<h1>foo</h1><h2>bar</h2>' );
+				const modelFragment = editor.data.parse( '<h1>foo</h1><h2>bar</h2>', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
 					.to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
 			} );
 			} );
 
 
 			it( 'should convert h1+h2 (in clipboard holder)', () => {
 			it( 'should convert h1+h2 (in clipboard holder)', () => {
-				const modelFragment = editor.data.parse( '<h1>foo</h1><h2>bar</h2>', '$clipboardHolder' );
+				const modelFragment = editor.data.parse( '<h1>foo</h1><h2>bar</h2>', batch, '$clipboardHolder' );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
 					.to.equal( '<paragraph>foo</paragraph><paragraph>bar</paragraph>' );
@@ -258,28 +257,28 @@ describe( 'Paragraph feature', () => {
 
 
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
 
 
-				const modelFragment = editor.data.parse( '<h1>foo</h1><h2>bar</h2><div>bom</div>', 'specialRoot' );
+				const modelFragment = editor.data.parse( '<h1>foo</h1><h2>bar</h2><div>bom</div>', batch, 'specialRoot' );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<div>bom</div>' );
 					.to.equal( '<div>bom</div>' );
 			} );
 			} );
 
 
 			it( 'should convert ul,ol>li', () => {
 			it( 'should convert ul,ol>li', () => {
-				const modelFragment = editor.data.parse( '<ul><li>a</li><li>b</li></ul><ol><li>c</li></ol>' );
+				const modelFragment = editor.data.parse( '<ul><li>a</li><li>b</li></ul><ol><li>c</li></ol>', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
 			} );
 			} );
 
 
 			it( 'should convert ul,ol>li (in clipboard holder)', () => {
 			it( 'should convert ul,ol>li (in clipboard holder)', () => {
-				const modelFragment = editor.data.parse( '<ul><li>a</li><li>b</li></ul><ol><li>c</li></ol>', '$clipboardHolder' );
+				const modelFragment = editor.data.parse( '<ul><li>a</li><li>b</li></ul><ol><li>c</li></ol>', batch, '$clipboardHolder' );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
 			} );
 			} );
 
 
 			it( 'should convert ul>li>ul>li+li', () => {
 			it( 'should convert ul>li>ul>li+li', () => {
-				const modelFragment = editor.data.parse( '<ul><li>a<ul><li>b</li><li>c</li></ul></li></ul>' );
+				const modelFragment = editor.data.parse( '<ul><li>a<ul><li>b</li><li>c</li></ul></li></ul>', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
@@ -288,14 +287,14 @@ describe( 'Paragraph feature', () => {
 			// "b" is not autoparagraphed because clipboard holder allows text nodes.
 			// "b" is not autoparagraphed because clipboard holder allows text nodes.
 			// There's a similar integrational test what's going to happen when pasting in paragraph-integration.js.
 			// There's a similar integrational test what's going to happen when pasting in paragraph-integration.js.
 			it( 'should convert ul>li>ul>li+li (in clipboard holder)', () => {
 			it( 'should convert ul>li>ul>li+li (in clipboard holder)', () => {
-				const modelFragment = editor.data.parse( '<ul><li>a<ul><li>b</li><li>c</li></ul></li></ul>', '$clipboardHolder' );
+				const modelFragment = editor.data.parse( '<ul><li>a<ul><li>b</li><li>c</li></ul></li></ul>', batch, '$clipboardHolder' );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph>' );
 			} );
 			} );
 
 
 			it( 'should convert ul>li>p,text', () => {
 			it( 'should convert ul>li>p,text', () => {
-				const modelFragment = editor.data.parse( '<ul><li><p>a</p>b</li></ul>' );
+				const modelFragment = editor.data.parse( '<ul><li><p>a</p>b</li></ul>', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph>' );
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph>' );
@@ -304,14 +303,17 @@ describe( 'Paragraph feature', () => {
 			// "b" is not autoparagraphed because clipboard holder allows text nodes.
 			// "b" is not autoparagraphed because clipboard holder allows text nodes.
 			// There's a similar integrational test what's going to happen when pasting in paragraph-integration.js.
 			// There's a similar integrational test what's going to happen when pasting in paragraph-integration.js.
 			it( 'should convert ul>li>p,text (in clipboard holder)', () => {
 			it( 'should convert ul>li>p,text (in clipboard holder)', () => {
-				const modelFragment = editor.data.parse( '<ul><li><p>a</p>b</li></ul>', '$clipboardHolder' );
+				const modelFragment = editor.data.parse( '<ul><li><p>a</p>b</li></ul>', batch, '$clipboardHolder' );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph>' );
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph>' );
 			} );
 			} );
 
 
 			it( 'should convert td', () => {
 			it( 'should convert td', () => {
-				const modelFragment = editor.data.parse( '<table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>' );
+				const modelFragment = editor.data.parse(
+					'<table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>',
+					batch
+				);
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph><paragraph>d</paragraph>' );
 					.to.equal( '<paragraph>a</paragraph><paragraph>b</paragraph><paragraph>c</paragraph><paragraph>d</paragraph>' );
@@ -320,6 +322,7 @@ describe( 'Paragraph feature', () => {
 			it( 'should convert td (in clipboardHolder)', () => {
 			it( 'should convert td (in clipboardHolder)', () => {
 				const modelFragment = editor.data.parse(
 				const modelFragment = editor.data.parse(
 					'<table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>',
 					'<table><tr><td>a</td><td>b</td></tr><tr><td>c</td><td>d</td></tr></table>',
+					batch,
 					'$clipboardHolder'
 					'$clipboardHolder'
 				);
 				);
 
 
@@ -334,7 +337,7 @@ describe( 'Paragraph feature', () => {
 
 
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
 				buildViewConverter().for( editor.data.viewToModel ).fromElement( 'div' ).toElement( 'div' );
 
 
-				const modelFragment = editor.data.parse( '<div><ul><li>foo</li><li>bar</li></ul></div><div>bom<p>bim</p></div>' );
+				const modelFragment = editor.data.parse( '<div><ul><li>foo</li><li>bar</li></ul></div><div>bom<p>bim</p></div>', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal(
 					.to.equal(
@@ -344,7 +347,7 @@ describe( 'Paragraph feature', () => {
 			} );
 			} );
 
 
 			it( 'should convert li inside disallowed container', () => {
 			it( 'should convert li inside disallowed container', () => {
-				const modelFragment = editor.data.parse( '<div><ul><li>foo</li><li>bar</li></ul></div><div>bom<p>bim</p></div>' );
+				const modelFragment = editor.data.parse( '<div><ul><li>foo</li><li>bar</li></ul></div><div>bom<p>bim</p></div>', batch );
 
 
 				expect( stringifyModel( modelFragment ) )
 				expect( stringifyModel( modelFragment ) )
 					.to.equal(
 					.to.equal(
@@ -354,7 +357,7 @@ describe( 'Paragraph feature', () => {
 			} );
 			} );
 
 
 			it( 'creates normalized model', () => {
 			it( 'creates normalized model', () => {
-				const modelFragment = editor.data.parse( '<h1><span>foo</span><span>bar</span>' );
+				const modelFragment = editor.data.parse( '<h1><span>foo</span><span>bar</span>', batch );
 
 
 				expect( stringifyModel( modelFragment ) ).to.equal( '<paragraph>foobar</paragraph>' );
 				expect( stringifyModel( modelFragment ) ).to.equal( '<paragraph>foobar</paragraph>' );
 
 
@@ -416,7 +419,7 @@ describe( 'Paragraph feature', () => {
 
 
 				if ( root.isEmpty ) {
 				if ( root.isEmpty ) {
 					doc.enqueueChanges( () => {
 					doc.enqueueChanges( () => {
-						doc.batch().insert( ModelPosition.createAt( root ), new ModelElement( 'heading' ) );
+						doc.batch().insertElement( 'heading', root );
 					} );
 					} );
 				}
 				}
 			} );
 			} );