Procházet zdrojové kódy

Test for disabled mention command.

Kuba Niegowski před 5 roky
rodič
revize
2489b5388c

+ 2 - 2
packages/ckeditor5-mention/src/mentionui.js

@@ -406,8 +406,8 @@ export default class MentionUI extends Plugin {
 			this._hideUIAndRemoveMarker();
 		} );
 
-		const command = editor.commands.get( 'mention' );
-		watcher.bind( 'isEnabled' ).to( command );
+		const mentionCommand = editor.commands.get( 'mention' );
+		watcher.bind( 'isEnabled' ).to( mentionCommand );
 
 		return watcher;
 	}

+ 19 - 0
packages/ckeditor5-mention/tests/mentionui.js

@@ -351,6 +351,25 @@ describe( 'MentionUI', () => {
 				} );
 		} );
 
+		it( 'should not show panel when command is disabled', () => {
+			return createClassicTestEditor( staticConfig )
+				.then( () => {
+					setData( model, '<paragraph>foo []</paragraph>' );
+
+					const mentionCommand = editor.commands.get( 'mention' );
+					mentionCommand.forceDisabled( 'mentionCommandDisableTest' );
+
+					model.change( writer => {
+						writer.insertText( '@', doc.selection.getFirstPosition() );
+					} );
+				} )
+				.then( waitForDebounce )
+				.then( () => {
+					expect( panelView.isVisible ).to.be.false;
+					expect( editor.model.markers.has( 'mention' ) ).to.be.false;
+				} );
+		} );
+
 		describe( 'static list with large set of results', () => {
 			const bigList = {
 				marker: '@',