浏览代码

Added a test which checks whether position of the media embed is correct.

Kamil Piechaczek 7 年之前
父节点
当前提交
8d529a5dba
共有 1 个文件被更改,包括 19 次插入0 次删除
  1. 19 0
      packages/ckeditor5-media-embed/tests/automediaembed.js

+ 19 - 0
packages/ckeditor5-media-embed/tests/automediaembed.js

@@ -317,6 +317,25 @@ describe( 'AutoMediaEmbed - integration', () => {
 			);
 		} );
 
+		it( 'inserts a new media element if pasted a link when other media element was selected in correct place', () => {
+			setData(
+				editor.model,
+				'<paragraph>Foo. <$text linkHref="https://cksource.com">Bar</$text></paragraph>' +
+				'[<media url="https://open.spotify.com/album/2IXlgvecaDqOeF3viUZnPI?si=ogVw7KlcQAGZKK4Jz9QzvA"></media>]' +
+				'<paragraph><$text bold="true">Bar</$text>.</paragraph>'
+			);
+
+			pasteHtml( editor, 'https://www.youtube.com/watch?v=H08tGjXNHO4' );
+
+			clock.tick( 100 );
+
+			expect( getData( editor.model ) ).to.equal(
+				'<paragraph>Foo. <$text linkHref="https://cksource.com">Bar</$text></paragraph>' +
+				'[<media url="https://www.youtube.com/watch?v=H08tGjXNHO4"></media>]' +
+				'<paragraph><$text bold="true">Bar</$text>.</paragraph>'
+			);
+		} );
+
 		it( 'does nothing if URL match to media but it was removed', () => {
 			return ClassicTestEditor
 				.create( editorElement, {