瀏覽代碼

Add tests for Undo + AutoLink.

Maciej Gołaszewski 5 年之前
父節點
當前提交
a283f19ffc
共有 1 個文件被更改,包括 26 次插入1 次删除
  1. 26 1
      packages/ckeditor5-link/tests/autolink.js

+ 26 - 1
packages/ckeditor5-link/tests/autolink.js

@@ -95,7 +95,7 @@ describe( 'AutoLink', () => {
 			);
 		} );
 
-		it( 'can undo auto-linking', () => {
+		it( 'can undo auto-linking (after space)', () => {
 			simulateTyping( 'https://www.cksource.com ' );
 
 			editor.commands.execute( 'undo' );
@@ -105,6 +105,31 @@ describe( 'AutoLink', () => {
 			);
 		} );
 
+		it( 'can undo auto-linking (after <softBreak>)', () => {
+			setData( model, '<paragraph>https://www.cksource.com[]</paragraph>' );
+
+			editor.execute( 'shiftEnter' );
+
+			editor.commands.execute( 'undo' );
+
+			expect( getData( model ) ).to.equal(
+				'<paragraph>https://www.cksource.com<softBreak></softBreak>[]</paragraph>'
+			);
+		} );
+
+		it( 'can undo auto-linking (after enter)', () => {
+			setData( model, '<paragraph>https://www.cksource.com[]</paragraph>' );
+
+			editor.execute( 'enter' );
+
+			editor.commands.execute( 'undo' );
+
+			expect( getData( model ) ).to.equal(
+				'<paragraph>https://www.cksource.com</paragraph>' +
+				'<paragraph>[]</paragraph>'
+			);
+		} );
+
 		function simulateTyping( text ) {
 			const letters = text.split( '' );