Browse Source

Add tests for mention with other feed marker character inside.

Maciej Gołaszewski 5 years ago
parent
commit
9a3c6d8b09
1 changed files with 42 additions and 1 deletions
  1. 42 1
      packages/ckeditor5-mention/tests/mentionui.js

+ 42 - 1
packages/ckeditor5-mention/tests/mentionui.js

@@ -1897,7 +1897,11 @@ describe( 'MentionUI', () => {
 						},
 						{
 							marker: '$',
-							feed: [ '$a1', '$a2', '$a3', '$a4', '$a5' ]
+							feed: [
+								'$a1', '$a2', '$a3', '$a4',
+								// A case of mention with a marker character from other feed. See #6398.
+								'$a@'
+							]
 						}
 					]
 				} );
@@ -1952,6 +1956,43 @@ describe( 'MentionUI', () => {
 						expect( mentionsView.items ).to.have.length( 3 );
 					} );
 			} );
+
+			it( 'should show panel for matched marker if it contains the other configured marker', () => {
+				setData( model, '<paragraph>foo []</paragraph>' );
+
+				model.change( writer => {
+					writer.insertText( '@', doc.selection.getFirstPosition() );
+				} );
+
+				return waitForDebounce()
+					.then( () => {
+						expect( panelView.isVisible ).to.be.true;
+						expect( editor.model.markers.has( 'mention' ) ).to.be.true;
+						expect( mentionsView.items ).to.have.length( 3 );
+
+						mentionsView.items.get( 0 ).children.get( 0 ).fire( 'execute' );
+					} )
+					.then( waitForDebounce )
+					.then( () => {
+						expect( panelView.isVisible ).to.be.false;
+						expect( editor.model.markers.has( 'mention' ) ).to.be.false;
+
+						model.change( writer => {
+							writer.insertText( '$a', doc.selection.getFirstPosition() );
+						} );
+					} )
+					.then( waitForDebounce )
+					.then( () => {
+						model.change( writer => {
+							writer.insertText( '@', doc.selection.getFirstPosition() );
+						} );
+					} )
+					.then( waitForDebounce )
+					.then( () => {
+						expect( panelView.isVisible ).to.be.true;
+						expect( editor.model.markers.has( 'mention' ) ).to.be.true;
+					} );
+			} );
 		} );
 
 		function testExecuteKey( name, keyCode, feedItems ) {