浏览代码

Add explicit tests for auto media embedding done in-place.

Maciej Gołaszewski 7 年之前
父节点
当前提交
db94521697
共有 1 个文件被更改,包括 14 次插入1 次删除
  1. 14 1
      packages/ckeditor5-media-embed/tests/automediaembed.js

+ 14 - 1
packages/ckeditor5-media-embed/tests/automediaembed.js

@@ -218,7 +218,7 @@ describe( 'AutoMediaEmbed - integration', () => {
 			);
 		} );
 
-		it( 'inserts media in-place', () => {
+		it( 'inserts media in-place (collapsed selection)', () => {
 			setData( editor.model, '<paragraph>Foo []Bar</paragraph>' );
 			pasteHtml( editor, 'https://www.youtube.com/watch?v=H08tGjXNHO4' );
 
@@ -231,6 +231,19 @@ describe( 'AutoMediaEmbed - integration', () => {
 			);
 		} );
 
+		it( 'inserts media in-place (non-collapsed selection)', () => {
+			setData( editor.model, '<paragraph>Foo [Bar] Baz</paragraph>' );
+			pasteHtml( editor, 'https://www.youtube.com/watch?v=H08tGjXNHO4' );
+
+			clock.tick( 100 );
+
+			expect( getData( editor.model ) ).to.equal(
+				'<paragraph>Foo </paragraph>' +
+				'[<media url="https://www.youtube.com/watch?v=H08tGjXNHO4"></media>]' +
+				'<paragraph> Baz</paragraph>'
+			);
+		} );
+
 		it( 'does nothing if a URL is invalid', () => {
 			setData( editor.model, '<paragraph>[]</paragraph>' );
 			pasteHtml( editor, 'https://youtube.com' );