Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mati365 committed Jun 17, 2024
1 parent 75395db commit 70f98d2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export default class DropdownMenuRootListView extends DropdownMenuListView {
*
* @observable
*/
private readonly _menuPanelClass: string | null;
private readonly _menuPanelClass: string | undefined;

/**
* The cached array of all menus in the dropdown menu.
Expand Down Expand Up @@ -144,7 +144,7 @@ export default class DropdownMenuRootListView extends DropdownMenuListView {
} );

this.editor = editor;
this._menuPanelClass = menuPanelClass || null;
this._menuPanelClass = menuPanelClass;
this._lazyInitializeSubMenus = !!lazyInitializeSubMenus;

this._setupIsOpenUpdater();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@ describe( 'DropdownMenuPanelView', () => {
} );

describe( 'constructor()', () => {
it( 'should have #children view collection', () => {
expect( panelView.children ).to.be.instanceOf( ViewCollection );
it( 'should have #content view collection', () => {
expect( panelView.content ).to.be.instanceOf( ViewCollection );

const view = new View();

view.setTemplate( { tag: 'div' } );
view.render();

panelView.render();
panelView.children.add( view );
panelView.content.add( view );

expect( panelView.element.firstChild ).to.equal( view.element );
} );
Expand Down Expand Up @@ -99,7 +99,7 @@ describe( 'DropdownMenuPanelView', () => {
panelView.element.dispatchEvent( selectStartEvent );
sinon.assert.calledOnce( spy );

panelView.children.add( labeledInput );
panelView.content.add( labeledInput );

labeledInput.fieldView.element.dispatchEvent( selectStartEvent );
sinon.assert.calledOnce( spy );
Expand All @@ -111,7 +111,7 @@ describe( 'DropdownMenuPanelView', () => {
const firstChildView = new View();
const lastChildView = new View();

panelView.children.addMany( [ firstChildView, lastChildView ] );
panelView.content.addMany( [ firstChildView, lastChildView ] );

firstChildView.focus = sinon.spy();
lastChildView.focus = sinon.spy();
Expand All @@ -126,7 +126,7 @@ describe( 'DropdownMenuPanelView', () => {
const firstChildView = new View();
const lastChildView = new View();

panelView.children.addMany( [ firstChildView, lastChildView ] );
panelView.content.addMany( [ firstChildView, lastChildView ] );

firstChildView.focus = sinon.spy();
lastChildView.focus = sinon.spy();
Expand Down
17 changes: 5 additions & 12 deletions packages/ckeditor5-ui/tests/dropdown/menu/dropdownmenuview.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,25 +193,17 @@ describe( 'DropdownMenuView', () => {
expect( menuView.panelView.position ).to.equal( newPositionName );
} );

it( 'should use the null position if none were considered optimal (because off the viewport, etc.)', () => {
sinon.stub( DropdownMenuView, '_getOptimalPosition' ).returns( null );

menuView.render();
menuView.panelView.position = null;
menuView.isOpen = true;

expect( menuView.panelView.position ).to.be.null;
} );

describe( 'when the UI language is LTR', () => {
it( 'should use a specific set of positioning functions in a specific priority order', () => {
const spy = sinon.spy( DropdownMenuView, '_getOptimalPosition' );
const locale = new Locale( { uiLanguage: 'pl' } );

createSubMenuWithLocale( locale );

const spy = sinon.spy( menuView.panelView, 'pin' );

menuView.isOpen = true;

expect( spy ).to.be.calledOnce;
expect( spy.firstCall.args[ 0 ].positions ).to.have.ordered.members( [
DropdownMenuViewPanelPositioningFunctions.eastSouth,
DropdownMenuViewPanelPositioningFunctions.eastNorth,
Expand All @@ -223,11 +215,12 @@ describe( 'DropdownMenuView', () => {

describe( 'when the UI language is RTL', () => {
it( 'should use a specific set of positioning functions in a specific priority order', () => {
const spy = sinon.spy( DropdownMenuView, '_getOptimalPosition' );
const locale = new Locale( { uiLanguage: 'ar' } );

createSubMenuWithLocale( locale );

const spy = sinon.spy( menuView.panelView, 'pin' );

menuView.isOpen = true;

expect( spy.firstCall.args[ 0 ].positions ).to.have.ordered.members( [
Expand Down

0 comments on commit 70f98d2

Please sign in to comment.