Răsfoiți Sursa

Added one more automated test.

Piotrek Koszuliński 9 ani în urmă
părinte
comite
0fa13eea73
1 a modificat fișierele cu 17 adăugiri și 0 ștergeri
  1. 17 0
      packages/ckeditor5-typing/tests/tickets/59/2.js

+ 17 - 0
packages/ckeditor5-typing/tests/tickets/59/2.js

@@ -29,6 +29,7 @@ describe( 'Bug #59', () => {
 
 	it( 'editor does not blow up when deleting last styled character', () => {
 		editor.document.enqueueChanges( () => {
+			editor.editing.view.getDomRoot().focus();
 			setData( editor.document, '<paragraph><$text bold="true">foo</$text> x <$text bold="true">bar</$text>.[]</paragraph>' );
 		} );
 
@@ -38,4 +39,20 @@ describe( 'Bug #59', () => {
 
 		expect( editor.getData() ).to.equal( '<p>&nbsp;</p>' );
 	} );
+
+	// This is something that came to my mind after I worked on ckeditor/ckeditor5-engine#659.
+	// Toggling bold at the end creates a lot of weird cases so it's interesting to see if it works... and it didn't back then.
+	it( 'editor does not blow up when deleting last styled character, forcing bold switch', () => {
+		editor.document.enqueueChanges( () => {
+			editor.editing.view.getDomRoot().focus();
+			setData( editor.document, '<paragraph><$text bold="true">foo</$text> x <$text bold="true">bar</$text>.[]</paragraph>' );
+		} );
+
+		while ( editor.document.selection.anchor.offset > 0 ) {
+			editor.execute( 'delete' );
+			editor.execute( 'bold' );
+		}
+
+		expect( editor.getData() ).to.equal( '<p>&nbsp;</p>' );
+	} );
 } );