Selaa lähdekoodia

Aligned test with engine changes.

Oskar Wróbel 8 vuotta sitten
vanhempi
commit
1f336b67b5

+ 55 - 56
packages/ckeditor5-basic-styles/tests/attributecommand.js

@@ -7,40 +7,39 @@ import AttributeCommand from '../src/attributecommand';
 
 import ModelTestEditor from '@ckeditor/ckeditor5-core/tests/_utils/modeltesteditor';
 
-import Document from '@ckeditor/ckeditor5-engine/src/model/document';
-import Batch from '@ckeditor/ckeditor5-engine/src/model/batch';
 import Range from '@ckeditor/ckeditor5-engine/src/model/range';
 import Position from '@ckeditor/ckeditor5-engine/src/model/position';
 import { setData, getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 describe( 'AttributeCommand', () => {
 	const attrKey = 'bold';
-	let editor, command, doc, root;
+	let editor, command, model, doc, root;
 
 	beforeEach( () => {
 		return ModelTestEditor
 			.create()
 			.then( newEditor => {
 				editor = newEditor;
-				doc = editor.document;
+				model = editor.model;
+				doc = model.document;
 				root = doc.getRoot();
 
 				command = new AttributeCommand( editor, attrKey );
 
-				doc.schema.registerItem( 'p', '$block' );
-				doc.schema.registerItem( 'h1', '$block' );
-				doc.schema.registerItem( 'img', '$inline' );
-				doc.schema.objects.add( 'img' );
+				model.schema.registerItem( 'p', '$block' );
+				model.schema.registerItem( 'h1', '$block' );
+				model.schema.registerItem( 'img', '$inline' );
+				model.schema.objects.add( 'img' );
 
 				// Allow block in "root" (DIV)
-				doc.schema.allow( { name: '$block', inside: '$root' } );
+				model.schema.allow( { name: '$block', inside: '$root' } );
 
 				// Bold text is allowed only in P.
-				doc.schema.allow( { name: '$text', attributes: 'bold', inside: 'p' } );
-				doc.schema.allow( { name: 'p', attributes: 'bold', inside: '$root' } );
+				model.schema.allow( { name: '$text', attributes: 'bold', inside: 'p' } );
+				model.schema.allow( { name: 'p', attributes: 'bold', inside: '$root' } );
 
 				// Disallow bold on image.
-				doc.schema.disallow( { name: 'img', attributes: 'bold', inside: '$root' } );
+				model.schema.disallow( { name: 'img', attributes: 'bold', inside: '$root' } );
 			} );
 	} );
 
@@ -52,7 +51,7 @@ describe( 'AttributeCommand', () => {
 
 	describe( 'value', () => {
 		it( 'is true when selection has the attribute', () => {
-			doc.enqueueChanges( () => {
+			model.change( () => {
 				doc.selection.setAttribute( attrKey, true );
 			} );
 
@@ -60,7 +59,7 @@ describe( 'AttributeCommand', () => {
 		} );
 
 		it( 'is false when selection does not have the attribute', () => {
-			doc.enqueueChanges( () => {
+			model.change( () => {
 				doc.selection.removeAttribute( attrKey );
 			} );
 
@@ -69,18 +68,18 @@ describe( 'AttributeCommand', () => {
 
 		// See https://github.com/ckeditor/ckeditor5-core/issues/73#issuecomment-311572827.
 		it( 'is false when selection contains object with nested editable', () => {
-			doc.schema.registerItem( 'caption', '$block' );
-			doc.schema.allow( { name: '$inline', inside: 'caption' } );
-			doc.schema.allow( { name: 'caption', inside: 'img' } );
-			doc.schema.allow( { name: '$text', attributes: 'bold', inside: 'caption' } );
+			model.schema.registerItem( 'caption', '$block' );
+			model.schema.allow( { name: '$inline', inside: 'caption' } );
+			model.schema.allow( { name: 'caption', inside: 'img' } );
+			model.schema.allow( { name: '$text', attributes: 'bold', inside: 'caption' } );
 
-			setData( doc, '<p>[<img><caption>Some caption inside the image.</caption></img>]</p>' );
+			setData( model, '<p>[<img><caption>Some caption inside the image.</caption></img>]</p>' );
 
 			expect( command.value ).to.be.false;
 			command.execute();
 			expect( command.value ).to.be.false;
 
-			expect( getData( doc ) ).to.equal(
+			expect( getData( model ) ).to.equal(
 				'<p>[<img><caption><$text bold="true">Some caption inside the image.</$text></caption></img>]</p>'
 			);
 		} );
@@ -91,30 +90,30 @@ describe( 'AttributeCommand', () => {
 		// Method `refresh()` uses `checkAttributeInSelection()` which is fully tested in its own test.
 
 		beforeEach( () => {
-			doc.schema.registerItem( 'x', '$block' );
-			doc.schema.disallow( { name: '$text', inside: 'x', attributes: 'link' } );
+			model.schema.registerItem( 'x', '$block' );
+			model.schema.disallow( { name: '$text', inside: 'x', attributes: 'link' } );
 		} );
 
 		describe( 'when selection is collapsed', () => {
 			it( 'should return true if characters with the attribute can be placed at caret position', () => {
-				setData( doc, '<p>f[]oo</p>' );
+				setData( model, '<p>f[]oo</p>' );
 				expect( command.isEnabled ).to.be.true;
 			} );
 
 			it( 'should return false if characters with the attribute cannot be placed at caret position', () => {
-				setData( doc, '<x>fo[]o</x>' );
+				setData( model, '<x>fo[]o</x>' );
 				expect( command.isEnabled ).to.be.false;
 			} );
 		} );
 
 		describe( 'when selection is not collapsed', () => {
 			it( 'should return true if there is at least one node in selection that can have the attribute', () => {
-				setData( doc, '<p>[foo]</p>' );
+				setData( model, '<p>[foo]</p>' );
 				expect( command.isEnabled ).to.be.true;
 			} );
 
 			it( 'should return false if there are no nodes in selection that can have the attribute', () => {
-				setData( doc, '<x>[foo]</x>' );
+				setData( model, '<x>[foo]</x>' );
 				expect( command.isEnabled ).to.be.false;
 			} );
 		} );
@@ -122,59 +121,59 @@ describe( 'AttributeCommand', () => {
 
 	describe( 'execute()', () => {
 		it( 'should do nothing if the command is disabled', () => {
-			setData( doc, '<p>fo[ob]ar</p>' );
+			setData( model, '<p>fo[ob]ar</p>' );
 
 			command.isEnabled = false;
 
 			command.execute();
 
-			expect( getData( doc ) ).to.equal( '<p>fo[ob]ar</p>' );
+			expect( getData( model ) ).to.equal( '<p>fo[ob]ar</p>' );
 		} );
 
 		it( 'should add attribute on selected nodes if the command value was false', () => {
-			setData( doc, '<p>a[bc<$text bold="true">fo]obar</$text>xyz</p>' );
+			setData( model, '<p>a[bc<$text bold="true">fo]obar</$text>xyz</p>' );
 
 			expect( command.value ).to.be.false;
 
 			command.execute();
 
 			expect( command.value ).to.be.true;
-			expect( getData( doc ) ).to.equal( '<p>a[<$text bold="true">bcfo]obar</$text>xyz</p>' );
+			expect( getData( model ) ).to.equal( '<p>a[<$text bold="true">bcfo]obar</$text>xyz</p>' );
 		} );
 
 		it( 'should remove attribute from selected nodes if the command value was true', () => {
-			setData( doc, '<p>abc[<$text bold="true">foo]bar</$text>xyz</p>' );
+			setData( model, '<p>abc[<$text bold="true">foo]bar</$text>xyz</p>' );
 
 			expect( command.value ).to.be.true;
 
 			command.execute();
 
-			expect( getData( doc ) ).to.equal( '<p>abc[foo]<$text bold="true">bar</$text>xyz</p>' );
+			expect( getData( model ) ).to.equal( '<p>abc[foo]<$text bold="true">bar</$text>xyz</p>' );
 			expect( command.value ).to.be.false;
 		} );
 
 		it( 'should add attribute on selected nodes if execute parameter was set to true', () => {
-			setData( doc, '<p>abc<$text bold="true">foob[ar</$text>x]yz</p>' );
+			setData( model, '<p>abc<$text bold="true">foob[ar</$text>x]yz</p>' );
 
 			expect( command.value ).to.be.true;
 
 			command.execute( { forceValue: true } );
 
 			expect( command.value ).to.be.true;
-			expect( getData( doc ) ).to.equal( '<p>abc<$text bold="true">foob[arx</$text>]yz</p>' );
+			expect( getData( model ) ).to.equal( '<p>abc<$text bold="true">foob[arx</$text>]yz</p>' );
 		} );
 
 		it( 'should remove attribute on selected nodes if execute parameter was set to false', () => {
-			setData( doc, '<p>a[bc<$text bold="true">fo]obar</$text>xyz</p>' );
+			setData( model, '<p>a[bc<$text bold="true">fo]obar</$text>xyz</p>' );
 
 			command.execute( { forceValue: false } );
 
 			expect( command.value ).to.be.false;
-			expect( getData( doc ) ).to.equal( '<p>a[bcfo]<$text bold="true">obar</$text>xyz</p>' );
+			expect( getData( model ) ).to.equal( '<p>a[bcfo]<$text bold="true">obar</$text>xyz</p>' );
 		} );
 
 		it( 'should change selection attribute if selection is collapsed in non-empty parent', () => {
-			setData( doc, '<p>a[]bc<$text bold="true">foobar</$text>xyz</p><p></p>' );
+			setData( model, '<p>a[]bc<$text bold="true">foobar</$text>xyz</p><p></p>' );
 
 			expect( command.value ).to.be.false;
 
@@ -190,13 +189,13 @@ describe( 'AttributeCommand', () => {
 		} );
 
 		it( 'should not store attribute change on selection if selection is collapsed in non-empty parent', () => {
-			setData( doc, '<p>a[]bc<$text bold="true">foobar</$text>xyz</p>' );
+			setData( model, '<p>a[]bc<$text bold="true">foobar</$text>xyz</p>' );
 
 			command.execute();
 
 			// It should not save that bold was executed at position ( root, [ 0, 1 ] ).
 
-			doc.enqueueChanges( () => {
+			model.change( () => {
 				// Simulate clicking right arrow key by changing selection ranges.
 				doc.selection.setRanges( [ new Range( new Position( root, [ 0, 2 ] ), new Position( root, [ 0, 2 ] ) ) ] );
 
@@ -208,7 +207,7 @@ describe( 'AttributeCommand', () => {
 		} );
 
 		it( 'should change selection attribute and store it if selection is collapsed in empty parent', () => {
-			setData( doc, '<p>abc<$text bold="true">foobar</$text>xyz</p><p>[]</p>' );
+			setData( model, '<p>abc<$text bold="true">foobar</$text>xyz</p><p>[]</p>' );
 
 			expect( command.value ).to.be.false;
 
@@ -219,14 +218,14 @@ describe( 'AttributeCommand', () => {
 
 			// Attribute should be stored.
 			// Simulate clicking somewhere else in the editor.
-			doc.enqueueChanges( () => {
+			model.change( () => {
 				doc.selection.setRanges( [ new Range( new Position( root, [ 0, 2 ] ), new Position( root, [ 0, 2 ] ) ) ] );
 			} );
 
 			expect( command.value ).to.be.false;
 
 			// Go back to where attribute was stored.
-			doc.enqueueChanges( () => {
+			model.change( () => {
 				doc.selection.setRanges( [ new Range( new Position( root, [ 1, 0 ] ), new Position( root, [ 1, 0 ] ) ) ] );
 			} );
 
@@ -240,27 +239,27 @@ describe( 'AttributeCommand', () => {
 		} );
 
 		it( 'should not apply attribute change where it would invalid schema', () => {
-			doc.schema.registerItem( 'image', '$block' );
-			setData( doc, '<p>ab[c<img></img><$text bold="true">foobar</$text>xy<img></img>]z</p>' );
+			model.schema.registerItem( 'image', '$block' );
+			setData( model, '<p>ab[c<img></img><$text bold="true">foobar</$text>xy<img></img>]z</p>' );
 
 			expect( command.isEnabled ).to.be.true;
 
 			command.execute();
 
-			expect( getData( doc ) )
+			expect( getData( model ) )
 				.to.equal( '<p>ab[<$text bold="true">c</$text><img></img><$text bold="true">foobarxy</$text><img></img>]z</p>' );
 		} );
 
-		it( 'should use provided batch for storing undo steps', () => {
-			const batch = new Batch( new Document() );
-			setData( doc, '<p>a[bc<$text bold="true">fo]obar</$text>xyz</p>' );
+		it( 'should use parent batch for storing undo steps', () => {
+			setData( model, '<p>a[bc<$text bold="true">fo]obar</$text>xyz</p>' );
 
-			expect( batch.deltas.length ).to.equal( 0 );
-
-			command.execute( { batch } );
+			model.change( writer => {
+				expect( writer.batch.deltas.length ).to.equal( 0 );
+				command.execute();
+				expect( writer.batch.deltas.length ).to.equal( 1 );
+			} );
 
-			expect( batch.deltas.length ).to.equal( 1 );
-			expect( getData( doc ) ).to.equal( '<p>a[<$text bold="true">bcfo]obar</$text>xyz</p>' );
+			expect( getData( model ) ).to.equal( '<p>a[<$text bold="true">bcfo]obar</$text>xyz</p>' );
 		} );
 
 		describe( 'should cause firing model document changesDone event', () => {
@@ -271,7 +270,7 @@ describe( 'AttributeCommand', () => {
 			} );
 
 			it( 'collapsed selection in non-empty parent', () => {
-				setData( doc, '<p>x[]y</p>' );
+				setData( model, '<p>x[]y</p>' );
 
 				doc.on( 'changesDone', spy );
 
@@ -281,7 +280,7 @@ describe( 'AttributeCommand', () => {
 			} );
 
 			it( 'non-collapsed selection', () => {
-				setData( doc, '<p>[xy]</p>' );
+				setData( model, '<p>[xy]</p>' );
 
 				doc.on( 'changesDone', spy );
 
@@ -291,7 +290,7 @@ describe( 'AttributeCommand', () => {
 			} );
 
 			it( 'in empty parent', () => {
-				setData( doc, '<p>[]</p>' );
+				setData( model, '<p>[]</p>' );
 
 				doc.on( 'changesDone', spy );
 

+ 10 - 11
packages/ckeditor5-basic-styles/tests/boldengine.js

@@ -13,7 +13,7 @@ import { getData as getModelData, setData as setModelData } from '@ckeditor/cked
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
 describe( 'BoldEngine', () => {
-	let editor, doc;
+	let editor, model;
 
 	beforeEach( () => {
 		return VirtualTestEditor
@@ -22,8 +22,7 @@ describe( 'BoldEngine', () => {
 			} )
 			.then( newEditor => {
 				editor = newEditor;
-
-				doc = editor.document;
+				model = editor.model;
 			} );
 	} );
 
@@ -36,9 +35,9 @@ describe( 'BoldEngine', () => {
 	} );
 
 	it( 'should set proper schema rules', () => {
-		expect( doc.schema.check( { name: '$inline', attributes: 'bold', inside: '$root' } ) ).to.be.false;
-		expect( doc.schema.check( { name: '$inline', attributes: 'bold', inside: '$block' } ) ).to.be.true;
-		expect( doc.schema.check( { name: '$inline', attributes: 'bold', inside: '$clipboardHolder' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', attributes: 'bold', inside: '$root' } ) ).to.be.false;
+		expect( model.schema.check( { name: '$inline', attributes: 'bold', inside: '$block' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', attributes: 'bold', inside: '$clipboardHolder' } ) ).to.be.true;
 	} );
 
 	describe( 'command', () => {
@@ -54,7 +53,7 @@ describe( 'BoldEngine', () => {
 		it( 'should convert <strong> to bold attribute', () => {
 			editor.setData( '<p><strong>foo</strong>bar</p>' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) )
+			expect( getModelData( model, { withoutSelection: true } ) )
 				.to.equal( '<paragraph><$text bold="true">foo</$text>bar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p><strong>foo</strong>bar</p>' );
@@ -63,7 +62,7 @@ describe( 'BoldEngine', () => {
 		it( 'should convert <b> to bold attribute', () => {
 			editor.setData( '<p><b>foo</b>bar</p>' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) )
+			expect( getModelData( model, { withoutSelection: true } ) )
 				.to.equal( '<paragraph><$text bold="true">foo</$text>bar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p><strong>foo</strong>bar</p>' );
@@ -72,7 +71,7 @@ describe( 'BoldEngine', () => {
 		it( 'should convert font-weight:bold to bold attribute', () => {
 			editor.setData( '<p><span style="font-weight: bold;">foo</span>bar</p>' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) )
+			expect( getModelData( model, { withoutSelection: true } ) )
 				.to.equal( '<paragraph><$text bold="true">foo</$text>bar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p><strong>foo</strong>bar</p>' );
@@ -84,7 +83,7 @@ describe( 'BoldEngine', () => {
 
 			editor.setData( '<strong>foo</strong>bar' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
+			expect( getModelData( model, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p>foobar</p>' );
 		} );
@@ -92,7 +91,7 @@ describe( 'BoldEngine', () => {
 
 	describe( 'editing pipeline conversion', () => {
 		it( 'should convert attribute', () => {
-			setModelData( doc, '<paragraph><$text bold="true">foo</$text>bar</paragraph>' );
+			setModelData( model, '<paragraph><$text bold="true">foo</$text>bar</paragraph>' );
 
 			expect( getViewData( editor.editing.view, { withoutSelection: true } ) ).to.equal( '<p><strong>foo</strong>bar</p>' );
 		} );

+ 9 - 10
packages/ckeditor5-basic-styles/tests/codeengine.js

@@ -13,7 +13,7 @@ import { getData as getModelData, setData as setModelData } from '@ckeditor/cked
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
 describe( 'CodeEngine', () => {
-	let editor, doc;
+	let editor, model;
 
 	beforeEach( () => {
 		return VirtualTestEditor
@@ -22,8 +22,7 @@ describe( 'CodeEngine', () => {
 			} )
 			.then( newEditor => {
 				editor = newEditor;
-
-				doc = editor.document;
+				model = editor.model;
 			} );
 	} );
 
@@ -36,9 +35,9 @@ describe( 'CodeEngine', () => {
 	} );
 
 	it( 'should set proper schema rules', () => {
-		expect( doc.schema.check( { name: '$inline', attributes: 'code', inside: '$root' } ) ).to.be.false;
-		expect( doc.schema.check( { name: '$inline', attributes: 'code', inside: '$block' } ) ).to.be.true;
-		expect( doc.schema.check( { name: '$inline', attributes: 'code', inside: '$clipboardHolder' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', attributes: 'code', inside: '$root' } ) ).to.be.false;
+		expect( model.schema.check( { name: '$inline', attributes: 'code', inside: '$block' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', attributes: 'code', inside: '$clipboardHolder' } ) ).to.be.true;
 	} );
 
 	describe( 'command', () => {
@@ -54,7 +53,7 @@ describe( 'CodeEngine', () => {
 		it( 'should convert <code> to code attribute', () => {
 			editor.setData( '<p><code>foo</code>bar</p>' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) )
+			expect( getModelData( model, { withoutSelection: true } ) )
 				.to.equal( '<paragraph><$text code="true">foo</$text>bar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p><code>foo</code>bar</p>' );
@@ -63,7 +62,7 @@ describe( 'CodeEngine', () => {
 		it( 'should convert word-wrap:break-word to code attribute', () => {
 			editor.setData( '<p><span style="word-wrap: break-word">foo</span>bar</p>' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) )
+			expect( getModelData( model, { withoutSelection: true } ) )
 				.to.equal( '<paragraph><$text code="true">foo</$text>bar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p><code>foo</code>bar</p>' );
@@ -75,7 +74,7 @@ describe( 'CodeEngine', () => {
 
 			editor.setData( '<code>foo</code>bar' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
+			expect( getModelData( model, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p>foobar</p>' );
 		} );
@@ -83,7 +82,7 @@ describe( 'CodeEngine', () => {
 
 	describe( 'editing pipeline conversion', () => {
 		it( 'should convert attribute', () => {
-			setModelData( doc, '<paragraph><$text code="true">foo</$text>bar</paragraph>' );
+			setModelData( model, '<paragraph><$text code="true">foo</$text>bar</paragraph>' );
 
 			expect( getViewData( editor.editing.view, { withoutSelection: true } ) ).to.equal( '<p><code>foo</code>bar</p>' );
 		} );

+ 10 - 11
packages/ckeditor5-basic-styles/tests/italicengine.js

@@ -13,7 +13,7 @@ import { getData as getModelData, setData as setModelData } from '@ckeditor/cked
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
 describe( 'ItalicEngine', () => {
-	let editor, doc;
+	let editor, model;
 
 	beforeEach( () => {
 		return VirtualTestEditor
@@ -22,8 +22,7 @@ describe( 'ItalicEngine', () => {
 			} )
 			.then( newEditor => {
 				editor = newEditor;
-
-				doc = editor.document;
+				model = editor.model;
 			} );
 	} );
 
@@ -36,9 +35,9 @@ describe( 'ItalicEngine', () => {
 	} );
 
 	it( 'should set proper schema rules', () => {
-		expect( doc.schema.check( { name: '$inline', attributes: 'italic', inside: '$root' } ) ).to.be.false;
-		expect( doc.schema.check( { name: '$inline', attributes: 'italic', inside: '$block' } ) ).to.be.true;
-		expect( doc.schema.check( { name: '$inline', attributes: 'italic', inside: '$clipboardHolder' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', attributes: 'italic', inside: '$root' } ) ).to.be.false;
+		expect( model.schema.check( { name: '$inline', attributes: 'italic', inside: '$block' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', attributes: 'italic', inside: '$clipboardHolder' } ) ).to.be.true;
 	} );
 
 	describe( 'command', () => {
@@ -54,7 +53,7 @@ describe( 'ItalicEngine', () => {
 		it( 'should convert <em> to italic attribute', () => {
 			editor.setData( '<p><em>foo</em>bar</p>' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) )
+			expect( getModelData( model, { withoutSelection: true } ) )
 				.to.equal( '<paragraph><$text italic="true">foo</$text>bar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p><i>foo</i>bar</p>' );
@@ -63,7 +62,7 @@ describe( 'ItalicEngine', () => {
 		it( 'should convert <i> to italic attribute', () => {
 			editor.setData( '<p><i>foo</i>bar</p>' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) )
+			expect( getModelData( model, { withoutSelection: true } ) )
 				.to.equal( '<paragraph><$text italic="true">foo</$text>bar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p><i>foo</i>bar</p>' );
@@ -72,7 +71,7 @@ describe( 'ItalicEngine', () => {
 		it( 'should convert font-weight:italic to italic attribute', () => {
 			editor.setData( '<p><span style="font-style: italic;">foo</span>bar</p>' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) )
+			expect( getModelData( model, { withoutSelection: true } ) )
 				.to.equal( '<paragraph><$text italic="true">foo</$text>bar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p><i>foo</i>bar</p>' );
@@ -84,7 +83,7 @@ describe( 'ItalicEngine', () => {
 
 			editor.setData( '<em>foo</em>bar' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
+			expect( getModelData( model, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p>foobar</p>' );
 		} );
@@ -92,7 +91,7 @@ describe( 'ItalicEngine', () => {
 
 	describe( 'editing pipeline conversion', () => {
 		it( 'should convert attribute', () => {
-			setModelData( doc, '<paragraph><$text italic="true">foo</$text>bar</paragraph>' );
+			setModelData( model, '<paragraph><$text italic="true">foo</$text>bar</paragraph>' );
 
 			expect( getViewData( editor.editing.view, { withoutSelection: true } ) ).to.equal( '<p><i>foo</i>bar</p>' );
 		} );

+ 9 - 10
packages/ckeditor5-basic-styles/tests/underlineengine.js

@@ -13,7 +13,7 @@ import { getData as getModelData, setData as setModelData } from '@ckeditor/cked
 import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils/view';
 
 describe( 'UnderlineEngine', () => {
-	let editor, doc;
+	let editor, model;
 
 	beforeEach( () => {
 		return VirtualTestEditor
@@ -22,8 +22,7 @@ describe( 'UnderlineEngine', () => {
 			} )
 			.then( newEditor => {
 				editor = newEditor;
-
-				doc = editor.document;
+				model = editor.model;
 			} );
 	} );
 
@@ -36,9 +35,9 @@ describe( 'UnderlineEngine', () => {
 	} );
 
 	it( 'should set proper schema rules', () => {
-		expect( doc.schema.check( { name: '$inline', attributes: 'underline', inside: '$root' } ) ).to.be.false;
-		expect( doc.schema.check( { name: '$inline', attributes: 'underline', inside: '$block' } ) ).to.be.true;
-		expect( doc.schema.check( { name: '$inline', attributes: 'underline', inside: '$clipboardHolder' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', attributes: 'underline', inside: '$root' } ) ).to.be.false;
+		expect( model.schema.check( { name: '$inline', attributes: 'underline', inside: '$block' } ) ).to.be.true;
+		expect( model.schema.check( { name: '$inline', attributes: 'underline', inside: '$clipboardHolder' } ) ).to.be.true;
 	} );
 
 	describe( 'command', () => {
@@ -54,7 +53,7 @@ describe( 'UnderlineEngine', () => {
 		it( 'should convert <u> to underline attribute', () => {
 			editor.setData( '<p><u>foo</u>bar</p>' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) )
+			expect( getModelData( model, { withoutSelection: true } ) )
 				.to.equal( '<paragraph><$text underline="true">foo</$text>bar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p><u>foo</u>bar</p>' );
@@ -63,7 +62,7 @@ describe( 'UnderlineEngine', () => {
 		it( 'should convert text-decoration:underline to underline attribute', () => {
 			editor.setData( '<p><span style="text-decoration: underline;">foo</span>bar</p>' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) )
+			expect( getModelData( model, { withoutSelection: true } ) )
 				.to.equal( '<paragraph><$text underline="true">foo</$text>bar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p><u>foo</u>bar</p>' );
@@ -75,7 +74,7 @@ describe( 'UnderlineEngine', () => {
 
 			editor.setData( '<u>foo</u>bar' );
 
-			expect( getModelData( doc, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
+			expect( getModelData( model, { withoutSelection: true } ) ).to.equal( '<paragraph>foobar</paragraph>' );
 
 			expect( editor.getData() ).to.equal( '<p>foobar</p>' );
 		} );
@@ -83,7 +82,7 @@ describe( 'UnderlineEngine', () => {
 
 	describe( 'editing pipeline conversion', () => {
 		it( 'should convert attribute', () => {
-			setModelData( doc, '<paragraph><$text underline="true">foo</$text>bar</paragraph>' );
+			setModelData( model, '<paragraph><$text underline="true">foo</$text>bar</paragraph>' );
 
 			expect( getViewData( editor.editing.view, { withoutSelection: true } ) ).to.equal( '<p><u>foo</u>bar</p>' );
 		} );