8
0
فهرست منبع

Add tests case to increase CC when splitting inside list.

The else statement in viewToModelListItemChildrenConverter() for
checking conditions after split wasn't covered after fixing
autoparagraphing. This tests does the "improper" way of setting
modelCursor when splitting to allowed parent.
Maciej Gołaszewski 6 سال پیش
والد
کامیت
7942abc0fe
1فایلهای تغییر یافته به همراه38 افزوده شده و 0 حذف شده
  1. 38 0
      packages/ckeditor5-list/tests/listediting.js

+ 38 - 0
packages/ckeditor5-list/tests/listediting.js

@@ -3869,6 +3869,44 @@ describe( 'ListEditing', () => {
 				'<listItem listIndent="2" listType="bulleted">C</listItem>'
 				'<listItem listIndent="2" listType="bulleted">C</listItem>'
 			);
 			);
 		} );
 		} );
+
+		it( 'should cover else branch', () => {
+			setModelData( model,
+				'<listItem listType="bulleted" listIndent="0">A[]</listItem>' +
+				'<listItem listType="bulleted" listIndent="1">B</listItem>' +
+				'<listItem listType="bulleted" listIndent="2">C</listItem>'
+			);
+
+			editor.model.schema.register( 'splitBlock', { inheritAllFrom: '$block' } );
+
+			editor.conversion.for( 'downcast' ).elementToElement( { model: 'splitBlock', view: 'splitBlock' } );
+			editor.conversion.for( 'upcast' ).add( dispatcher => dispatcher.on( 'element:splitBlock', ( evt, data, conversionApi ) => {
+				conversionApi.consumable.consume( data.viewItem, { name: true } );
+
+				// Use split to allowed parent logic to simulate the "improper" use modelCursor after split (set.
+				const splitBlock = conversionApi.writer.createElement( 'splitBlock' );
+				const splitResult = conversionApi.splitToAllowedParent( splitBlock, data.modelCursor );
+
+				conversionApi.writer.insert( splitBlock, splitResult.position );
+
+				data.modelRange = conversionApi.writer.createRangeOn( splitBlock );
+				data.modelCursor = conversionApi.writer.createPositionAfter( splitBlock );
+			} ) );
+
+			const clipboard = editor.plugins.get( 'Clipboard' );
+
+			clipboard.fire( 'inputTransformation', {
+				content: parseView( '<ul><li>a<splitBlock></splitBlock>b</li></ul>' )
+			} );
+
+			expect( getModelData( model, { withoutSelection: true } ) ).to.equal(
+				'<listItem listIndent="0" listType="bulleted">Aa</listItem>' +
+				'<splitBlock></splitBlock>' +
+				'<listItem listIndent="0" listType="bulleted">b</listItem>' +
+				'<listItem listIndent="1" listType="bulleted">B</listItem>' +
+				'<listItem listIndent="2" listType="bulleted">C</listItem>'
+			);
+		} );
 	} );
 	} );
 
 
 	describe( 'other', () => {
 	describe( 'other', () => {