Parcourir la source

Added missing batch to the conversion api.

Oskar Wróbel il y a 8 ans
Parent
commit
29f325239a
1 fichiers modifiés avec 10 ajouts et 9 suppressions
  1. 10 9
      packages/ckeditor5-image/tests/image/converters.js

+ 10 - 9
packages/ckeditor5-image/tests/image/converters.js

@@ -22,13 +22,14 @@ import { getData as getViewData } from '@ckeditor/ckeditor5-engine/src/dev-utils
 import { setData as setModelData, getData as getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 import { setData as setModelData, getData as getModelData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 
 describe( 'Image converters', () => {
 describe( 'Image converters', () => {
-	let editor, document, viewDocument;
+	let editor, document, viewDocument, batch;
 
 
 	beforeEach( () => {
 	beforeEach( () => {
 		return VirtualTestEditor.create()
 		return VirtualTestEditor.create()
 			.then( newEditor => {
 			.then( newEditor => {
 				editor = newEditor;
 				editor = newEditor;
 				document = editor.document;
 				document = editor.document;
+				batch = document.batch();
 				viewDocument = editor.editing.view;
 				viewDocument = editor.editing.view;
 				const schema = document.schema;
 				const schema = document.schema;
 
 
@@ -230,7 +231,7 @@ describe( 'Image converters', () => {
 
 
 		describe( 'convertHoistableImage', () => {
 		describe( 'convertHoistableImage', () => {
 			it( 'should convert img element using already added converters if it is allowed in any point of given context #1', () => {
 			it( 'should convert img element using already added converters if it is allowed in any point of given context #1', () => {
-				const result = dispatcher.convert( viewImg, { context: [ '$root', 'div', 'paragraph' ] } );
+				const result = dispatcher.convert( viewImg, { context: [ '$root', 'div', 'paragraph' ], batch } );
 
 
 				// `result` is a model document fragment.
 				// `result` is a model document fragment.
 				expect( result.childCount ).to.equal( 1 );
 				expect( result.childCount ).to.equal( 1 );
@@ -240,7 +241,7 @@ describe( 'Image converters', () => {
 			} );
 			} );
 
 
 			it( 'should convert img element using already added converters if it is allowed in any point of given context #2', () => {
 			it( 'should convert img element using already added converters if it is allowed in any point of given context #2', () => {
-				const result = dispatcher.convert( viewImg, { context: [ '$root', modelDiv, modelParagraph ] } );
+				const result = dispatcher.convert( viewImg, { context: [ '$root', modelDiv, modelParagraph ], batch } );
 
 
 				// `result` is a model document fragment.
 				// `result` is a model document fragment.
 				expect( result.childCount ).to.equal( 1 );
 				expect( result.childCount ).to.equal( 1 );
@@ -250,7 +251,7 @@ describe( 'Image converters', () => {
 			} );
 			} );
 
 
 			it( 'should not convert img element if there is no allowed context #1', () => {
 			it( 'should not convert img element if there is no allowed context #1', () => {
-				const result = dispatcher.convert( viewImg, { context: [ 'div', 'paragraph' ] } );
+				const result = dispatcher.convert( viewImg, { context: [ 'div', 'paragraph' ], batch } );
 
 
 				// `result` is an empty model document fragment.
 				// `result` is an empty model document fragment.
 				expect( result.childCount ).to.equal( 0 );
 				expect( result.childCount ).to.equal( 0 );
@@ -258,7 +259,7 @@ describe( 'Image converters', () => {
 			} );
 			} );
 
 
 			it( 'should not convert img element if there is no allowed context #2', () => {
 			it( 'should not convert img element if there is no allowed context #2', () => {
-				const result = dispatcher.convert( viewImg, { context: [ modelDiv, modelParagraph ] } );
+				const result = dispatcher.convert( viewImg, { context: [ modelDiv, modelParagraph ], batch } );
 
 
 				// `result` is an empty model document fragment.
 				// `result` is an empty model document fragment.
 				expect( result.childCount ).to.equal( 0 );
 				expect( result.childCount ).to.equal( 0 );
@@ -268,7 +269,7 @@ describe( 'Image converters', () => {
 			it( 'should not convert img element if allowed context is "above" limiting element #1', () => {
 			it( 'should not convert img element if allowed context is "above" limiting element #1', () => {
 				schema.limits.add( 'limit' );
 				schema.limits.add( 'limit' );
 
 
-				const result = dispatcher.convert( viewImg, { context: [ '$root', 'limit', 'div', 'paragraph' ] } );
+				const result = dispatcher.convert( viewImg, { context: [ '$root', 'limit', 'div', 'paragraph' ], batch } );
 
 
 				// `result` is an empty model document fragment.
 				// `result` is an empty model document fragment.
 				expect( result.childCount ).to.equal( 0 );
 				expect( result.childCount ).to.equal( 0 );
@@ -278,7 +279,7 @@ describe( 'Image converters', () => {
 			it( 'should not convert img element if allowed context is "above" limiting element #2', () => {
 			it( 'should not convert img element if allowed context is "above" limiting element #2', () => {
 				schema.limits.add( 'limit' );
 				schema.limits.add( 'limit' );
 
 
-				const result = dispatcher.convert( viewImg, { context: [ '$root', modelLimit, modelDiv, modelParagraph ] } );
+				const result = dispatcher.convert( viewImg, { context: [ '$root', modelLimit, modelDiv, modelParagraph ], batch } );
 
 
 				// `result` is an empty model document fragment.
 				// `result` is an empty model document fragment.
 				expect( result.childCount ).to.equal( 0 );
 				expect( result.childCount ).to.equal( 0 );
@@ -300,7 +301,7 @@ describe( 'Image converters', () => {
 				// because image is not allowed in div.
 				// because image is not allowed in div.
 				const viewDiv = new ViewContainerElement( 'div', null, [ 'foo', viewImg, 'bar' ] );
 				const viewDiv = new ViewContainerElement( 'div', null, [ 'foo', viewImg, 'bar' ] );
 
 
-				const result = dispatcher.convert( viewDiv, { context: [ '$root' ] } );
+				const result = dispatcher.convert( viewDiv, { context: [ '$root' ], batch } );
 
 
 				// `result` is a model document fragment.
 				// `result` is a model document fragment.
 				expect( result.childCount ).to.equal( 3 );
 				expect( result.childCount ).to.equal( 3 );
@@ -319,7 +320,7 @@ describe( 'Image converters', () => {
 
 
 				const viewDiv = new ViewContainerElement( 'p', null, [ 'foo', viewImg, 'bar' ] );
 				const viewDiv = new ViewContainerElement( 'p', null, [ 'foo', viewImg, 'bar' ] );
 
 
-				const result = dispatcher.convert( viewDiv, { context: [ '$root', 'div' ] } );
+				const result = dispatcher.convert( viewDiv, { context: [ '$root', 'div' ], batch } );
 
 
 				// `result` is a model document fragment.
 				// `result` is a model document fragment.
 				expect( result.childCount ).to.equal( 3 );
 				expect( result.childCount ).to.equal( 3 );