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

Merge pull request #50 from ckeditor/t/49

Tests: Added a test which checks whether the command has the proper attributes for objects with nested editable. Closes #49.
Piotrek Koszuliński 8 лет назад
Родитель
Сommit
bc0cc29dd1
1 измененных файлов с 19 добавлено и 0 удалено
  1. 19 0
      packages/ckeditor5-basic-styles/tests/attributecommand.js

+ 19 - 0
packages/ckeditor5-basic-styles/tests/attributecommand.js

@@ -30,6 +30,7 @@ describe( 'AttributeCommand', () => {
 				doc.schema.registerItem( 'p', '$block' );
 				doc.schema.registerItem( 'h1', '$block' );
 				doc.schema.registerItem( 'img', '$inline' );
+				doc.schema.objects.add( 'img' );
 
 				// Allow block in "root" (DIV)
 				doc.schema.allow( { name: '$block', inside: '$root' } );
@@ -65,6 +66,24 @@ describe( 'AttributeCommand', () => {
 
 			expect( command.value ).to.be.false;
 		} );
+
+		// 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' } );
+
+			setData( doc, '<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(
+				'<p>[<img><caption><$text bold="true">Some caption inside the image.</$text></caption></img>]</p>'
+			);
+		} );
 	} );
 
 	describe( 'isEnabled', () => {