Преглед на файлове

Added inline autoformat test.

Maksymilian Barnaś преди 9 години
родител
ревизия
a9f259b6aa
променени са 1 файла, в които са добавени 29 реда и са изтрити 0 реда
  1. 29 0
      packages/ckeditor5-autoformat/tests/autoformat.js

+ 29 - 0
packages/ckeditor5-autoformat/tests/autoformat.js

@@ -103,4 +103,33 @@ describe( 'Autoformat', () => {
 			expect( getData( doc ) ).to.equal( '<heading1># []</heading1>' );
 		} );
 	} );
+
+	describe( 'Inline autoformat', () => {
+		it( 'should replace both `**` with bold', () => {
+			setData( doc, '<paragraph>**foobar*[]</paragraph>' );
+			doc.enqueueChanges( () => {
+				batch.insert( doc.selection.getFirstPosition(), '*' );
+			} );
+
+			expect( getData( doc ) ).to.equal( '<paragraph><$text bold="true">foobar[]</$text></paragraph>' );
+		} );
+
+		it( 'should replace both `*` with italic', () => {
+			setData( doc, '<paragraph>*foobar[]</paragraph>' );
+			doc.enqueueChanges( () => {
+				batch.insert( doc.selection.getFirstPosition(), '*' );
+			} );
+
+			expect( getData( doc ) ).to.equal( '<paragraph><$text italic="true">foobar[]</$text></paragraph>' );
+		} );
+
+		it( 'nothing should be replaces when typing `*`', () => {
+			setData( doc, '<paragraph>foobar[]</paragraph>' );
+			doc.enqueueChanges( () => {
+				batch.insert( doc.selection.getFirstPosition(), '*' );
+			} );
+
+			expect( getData( doc ) ).to.equal( '<paragraph>foobar*[]</paragraph>' );
+		} );
+	} );
 } );