diff --git a/packages/ckeditor5-mention/tests/mentionui.js b/packages/ckeditor5-mention/tests/mentionui.js
index 7df2a81da39..4deca6ef8e6 100644
--- a/packages/ckeditor5-mention/tests/mentionui.js
+++ b/packages/ckeditor5-mention/tests/mentionui.js
@@ -300,70 +300,68 @@ describe( 'MentionUI', () => {
} );
} );
- describe( 'contextual balloon in rtl', () => {
- let contextualBaloonSpy;
+ describe( 'relation with the UI language direction of the editor', () => {
+ describe( 'for RTL languages', () => {
+ let contextualBaloonSpy;
- beforeEach( async () => {
- await editor.destroy();
-
- return createClassicTestEditor( { ...staticConfig } )
- .then( () => {
- const contextualBalloon = editor.plugins.get( ContextualBalloon );
- setData( model, 'foo []' );
- editor.locale.uiLanguageDirection = 'rtl';
- contextualBaloonSpy = sinon.spy( contextualBalloon, 'add' );
+ beforeEach( async () => {
+ await editor.destroy();
- model.change( writer => {
- writer.insertText( '@', doc.selection.getFirstPosition() );
- } );
- } )
- .then( waitForDebounce );
- } );
+ return createClassicTestEditor( { ...staticConfig } )
+ .then( () => {
+ const contextualBalloon = editor.plugins.get( ContextualBalloon );
+ setData( model, 'foo []' );
+ editor.locale.uiLanguageDirection = 'rtl';
+ contextualBaloonSpy = sinon.spy( contextualBalloon, 'add' );
- it( 'should set proper position list in rtl', () => {
- const extractedPositions = contextualBaloonSpy.getCall( 0 ).firstArg.position.positions.map( callback => {
- return callback( {}, {} ).name;
+ model.change( writer => {
+ writer.insertText( '@', doc.selection.getFirstPosition() );
+ } );
+ } )
+ .then( waitForDebounce );
} );
- expect( extractedPositions ).to.have.ordered.members( [
- 'caret_sw',
- 'caret_se',
- 'caret_nw',
- 'caret_ne'
- ] );
- } );
- } );
+ it( 'should prefer the west position first (to the left of the caret)', () => {
+ const positionNames = contextualBaloonSpy.firstCall.firstArg.position.positions.map( ( { name } ) => name );
- describe( 'contextual balloon in ltr', () => {
- let contextualBaloonSpy;
+ expect( positionNames ).to.have.ordered.members( [
+ 'caret_sw',
+ 'caret_se',
+ 'caret_nw',
+ 'caret_ne'
+ ] );
+ } );
+ } );
- beforeEach( async () => {
- await editor.destroy();
+ describe( 'for ltr languages', () => {
+ let contextualBaloonSpy;
- return createClassicTestEditor( { ...staticConfig } )
- .then( () => {
- const contextualBalloon = editor.plugins.get( ContextualBalloon );
- setData( model, 'foo []' );
- contextualBaloonSpy = sinon.spy( contextualBalloon, 'add' );
+ beforeEach( async () => {
+ await editor.destroy();
- model.change( writer => {
- writer.insertText( '@', doc.selection.getFirstPosition() );
- } );
- } )
- .then( waitForDebounce );
- } );
+ return createClassicTestEditor( { ...staticConfig } )
+ .then( () => {
+ const contextualBalloon = editor.plugins.get( ContextualBalloon );
+ setData( model, 'foo []' );
+ contextualBaloonSpy = sinon.spy( contextualBalloon, 'add' );
- it( 'should set proper position list in ltr', () => {
- const extractedPositions = contextualBaloonSpy.getCall( 0 ).firstArg.position.positions.map( callback => {
- return callback( {}, {} ).name;
+ model.change( writer => {
+ writer.insertText( '@', doc.selection.getFirstPosition() );
+ } );
+ } )
+ .then( waitForDebounce );
} );
- expect( extractedPositions ).to.have.ordered.members( [
- 'caret_se',
- 'caret_sw',
- 'caret_ne',
- 'caret_nw'
- ] );
+ it( 'should prefer the east position first (to the right of the caret)', () => {
+ const positionNames = contextualBaloonSpy.firstCall.firstArg.position.positions.map( ( { name } ) => name );
+
+ expect( positionNames ).to.have.ordered.members( [
+ 'caret_se',
+ 'caret_sw',
+ 'caret_ne',
+ 'caret_nw'
+ ] );
+ } );
} );
} );
} );