Explorar el Código

Tests: Added a test that checks the SelectAllCommand in a deeper nested editable structure.

Aleksander Nowodzinski hace 5 años
padre
commit
ab3b50a5a1
Se han modificado 1 ficheros con 29 adiciones y 1 borrados
  1. 29 1
      packages/ckeditor5-select-all/tests/selectallcommand.js

+ 29 - 1
packages/ckeditor5-select-all/tests/selectallcommand.js

@@ -8,6 +8,7 @@ import SelectAllEditing from '../src/selectallediting';
 import Paragraph from '@ckeditor/ckeditor5-paragraph/src/paragraph';
 import ImageEditing from '@ckeditor/ckeditor5-image/src/image/imageediting';
 import ImageCaptionEditing from '@ckeditor/ckeditor5-image/src/imagecaption/imagecaptionediting';
+import TableEditing from '@ckeditor/ckeditor5-table/src/tableediting';
 import { setData, getData } from '@ckeditor/ckeditor5-engine/src/dev-utils/model';
 
 describe( 'SelectAllCommand', () => {
@@ -16,7 +17,7 @@ describe( 'SelectAllCommand', () => {
 	beforeEach( () => {
 		return ModelTestEditor
 			.create( {
-				plugins: [ SelectAllEditing, Paragraph, ImageEditing, ImageCaptionEditing ]
+				plugins: [ SelectAllEditing, Paragraph, ImageEditing, ImageCaptionEditing, TableEditing ]
 			} )
 			.then( newEditor => {
 				editor = newEditor;
@@ -75,5 +76,32 @@ describe( 'SelectAllCommand', () => {
 
 			expect( getData( model ) ).to.equal( '<paragraph>foo</paragraph><image src="foo.png"><caption>[bar]</caption></image>' );
 		} );
+
+		it( 'should select all in the closest nested editable (nested editable inside another nested editable)', () => {
+			setData( model,
+				'<paragraph>foo</paragraph>' +
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell>' +
+							'<paragraph>foo</paragraph>' +
+							'<image src="foo.png"><caption>b[]ar</caption></image>' +
+						'</tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+
+			editor.execute( 'selectAll' );
+
+			expect( getData( model ) ).to.equal( '<paragraph>foo</paragraph>' +
+				'<table>' +
+					'<tableRow>' +
+						'<tableCell>' +
+							'<paragraph>foo</paragraph>' +
+							'<image src="foo.png"><caption>[bar]</caption></image>' +
+						'</tableCell>' +
+					'</tableRow>' +
+				'</table>'
+			);
+		} );
 	} );
 } );