浏览代码

Aligned test with engine changes.

Oskar Wróbel 8 年之前
父节点
当前提交
ec9b031482
共有 2 个文件被更改,包括 28 次插入24 次删除
  1. 14 10
      packages/ckeditor5-clipboard/tests/clipboard.js
  2. 14 14
      packages/ckeditor5-clipboard/tests/pasting-integration.js

+ 14 - 10
packages/ckeditor5-clipboard/tests/clipboard.js

@@ -279,7 +279,7 @@ describe( 'Clipboard feature', () => {
 			const dataTransferMock = createDataTransfer();
 			const preventDefaultSpy = sinon.spy();
 
-			setModelData( editor.document, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
+			setModelData( editor.model, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
 
 			editingView.on( 'clipboardOutput', ( evt, data ) => {
 				expect( preventDefaultSpy.calledOnce ).to.be.true;
@@ -303,7 +303,7 @@ describe( 'Clipboard feature', () => {
 			const dataTransferMock = createDataTransfer();
 			const preventDefaultSpy = sinon.spy();
 
-			setModelData( editor.document, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
+			setModelData( editor.model, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
 
 			editingView.on( 'clipboardOutput', ( evt, data ) => {
 				expect( data.method ).to.equal( 'cut' );
@@ -322,7 +322,7 @@ describe( 'Clipboard feature', () => {
 			const preventDefaultSpy = sinon.spy();
 			const spy = sinon.spy();
 
-			setModelData( editor.document, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
+			setModelData( editor.model, '<paragraph>a[bc</paragraph><paragraph>de]f</paragraph>' );
 			editor.isReadOnly = true;
 
 			editingView.on( 'clipboardOutput', spy );
@@ -466,16 +466,20 @@ describe( 'Clipboard feature', () => {
 		it( 'deletes selected content in case of cut', () => {
 			const dataTransferMock = createDataTransfer();
 
-			setModelData( editor.document, '<paragraph>f[o</paragraph><paragraph>x]o</paragraph>' );
+			setModelData( editor.model, '<paragraph>f[o</paragraph><paragraph>x]o</paragraph>' );
 
-			editingView.fire( 'clipboardOutput', {
-				dataTransfer: dataTransferMock,
-				content: new ViewDocumentFragment(),
-				method: 'cut',
-				batch: editor.document.batch()
+			// Change block is only to get writer instance.
+			// Writer should not be passed along this event.
+			editor.model.change( writer => {
+				editingView.fire( 'clipboardOutput', {
+					dataTransfer: dataTransferMock,
+					content: new ViewDocumentFragment(),
+					method: 'cut',
+					writer
+				} );
 			} );
 
-			expect( getModelData( editor.document ) ).to.equal( '<paragraph>f[]o</paragraph>' );
+			expect( getModelData( editor.model ) ).to.equal( '<paragraph>f[]o</paragraph>' );
 		} );
 
 		it( 'uses low priority observer for the clipboardOutput event', () => {

+ 14 - 14
packages/ckeditor5-clipboard/tests/pasting-integration.js

@@ -34,11 +34,11 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>[]</paragraph>' );
+					setData( editor.model, '<paragraph>[]</paragraph>' );
 
 					pasteHtml( editor, 'x <strong>bold</strong> <i>italic</i> <a href="x">link</a> y' );
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'x <$text bold="true">bold</$text> <$text italic="true">italic</$text> ' +
 							'<$text linkHref="x">link</$text> y[]' +
@@ -53,11 +53,11 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>[]</paragraph>' );
+					setData( editor.model, '<paragraph>[]</paragraph>' );
 
 					pasteHtml( editor, '<p>x <strong>bold</strong> <i>italic</i> <a href="x">link</a> y</p>' );
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'x <$text bold="true">bold</$text> <$text italic="true">italic</$text> ' +
 							'<$text linkHref="x">link</$text> y[]' +
@@ -72,11 +72,11 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>[]</paragraph>' );
+					setData( editor.model, '<paragraph>[]</paragraph>' );
 
 					pasteHtml( editor, '<div>x <strong>bold</strong> <i>italic</i> <a href="x">link</a> y</div>' );
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'x <$text bold="true">bold</$text> <$text italic="true">italic</$text> ' +
 							'<$text linkHref="x">link</$text> y[]' +
@@ -91,11 +91,11 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, BlockQuote, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>[]</paragraph>' );
+					setData( editor.model, '<paragraph>[]</paragraph>' );
 
 					pasteHtml( editor, '<blockquote>x <strong>bold</strong> <i>italic</i> <a href="x">link</a> y</blockquote>' );
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<blockQuote><paragraph>x bold italic link y[]</paragraph></blockQuote>'
 					);
 
@@ -122,7 +122,7 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>x[]y</paragraph>' );
+					setData( editor.model, '<paragraph>x[]y</paragraph>' );
 
 					pasteHtml( editor,
 						'<meta charset=\'utf-8\'>' +
@@ -133,7 +133,7 @@ describe( 'Pasting – integration', () => {
 						'<span style="color: rgb(0, 0, 0); font-family: Times;">.</span>'
 					);
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'xThis is the ' +
 							'<$text linkHref="url">third developer preview</$text> of <$text bold="true">CKEditor\u00a05</$text>' +
@@ -150,7 +150,7 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>x[]y</paragraph>' );
+					setData( editor.model, '<paragraph>x[]y</paragraph>' );
 
 					/* eslint-disable max-len */
 					pasteHtml( editor,
@@ -162,7 +162,7 @@ describe( 'Pasting – integration', () => {
 					);
 					/* eslint-enable max-len */
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'xThis is the ' +
 							'<$text linkHref="url">third developer preview</$text> of <$text bold="true">CKEditor\u00a05</$text>' +
@@ -178,7 +178,7 @@ describe( 'Pasting – integration', () => {
 			return ClassicTestEditor
 				.create( element, { plugins: [ Clipboard, Paragraph, Bold, Italic, Link ] } )
 				.then( editor => {
-					setData( editor.document, '<paragraph>x[]y</paragraph>' );
+					setData( editor.model, '<paragraph>x[]y</paragraph>' );
 
 					// Note, when copying the HTML from Firefox's console you'll see only normal spaces,
 					// but when you check it later in the model it's still an nbsp.
@@ -186,7 +186,7 @@ describe( 'Pasting – integration', () => {
 						'This is the <a href="url">third developer preview</a> of <strong>CKEditor\u00a05</strong>.'
 					);
 
-					expect( getData( editor.document ) ).to.equal(
+					expect( getData( editor.model ) ).to.equal(
 						'<paragraph>' +
 							'xThis is the ' +
 							'<$text linkHref="url">third developer preview</$text> of <$text bold="true">CKEditor\u00a05</$text>' +