-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix native BlockAlignmentControl (#35191)
* Fix native BlockAlignmentControl A recent web-centric change introduced usage of `MenuGroup` and `MenuItem`, both of which are unsupported in the native editor currently. This updates the conditional within `BlockAlignmentControl` to reinstate the previous UI for the native platform. * Fix nuanced test irregularities Rename mistakenly named assignments, which were misleading. Additionally, the reliance upon the default `value="left"` could lead to a false-positive test. Changing to a none-default of `value="right"` improves the validity of the test. * Fix inconsistent test description Co-authored-by: Carlos Garcia <[email protected]> Co-authored-by: Carlos Garcia <[email protected]>
- Loading branch information
Showing
3 changed files
with
107 additions
and
63 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
packages/block-editor/src/components/block-alignment-control/test/index.native.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { render, fireEvent } from 'test/helpers'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import BlockAlignmentUI from '../ui'; | ||
|
||
it( 'should call onChange with undefined when the control is already active', () => { | ||
const onChangeMock = jest.fn(); | ||
const screen = render( | ||
<BlockAlignmentUI value="right" onChange={ onChangeMock } /> | ||
); | ||
const alignButton = screen.getByA11yLabel( 'Align' ); | ||
fireEvent.press( alignButton ); | ||
const rightAlignmentButton = screen.getByA11yLabel( 'Align right' ); | ||
fireEvent.press( rightAlignmentButton ); | ||
|
||
expect( onChangeMock ).toHaveBeenCalledTimes( 1 ); | ||
expect( onChangeMock ).toHaveBeenCalledWith( undefined ); | ||
} ); | ||
|
||
it( 'should call onChange with alignment value when the control is inactive', () => { | ||
const onChangeMock = jest.fn(); | ||
const screen = render( | ||
<BlockAlignmentUI value="left" onChange={ onChangeMock } /> | ||
); | ||
const alignButton = screen.getByA11yLabel( 'Align' ); | ||
fireEvent.press( alignButton ); | ||
const centerAlignmentButton = screen.getByA11yLabel( 'Align center' ); | ||
fireEvent.press( centerAlignmentButton ); | ||
|
||
expect( onChangeMock ).toHaveBeenCalledTimes( 1 ); | ||
expect( onChangeMock ).toHaveBeenCalledWith( 'center' ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -135,4 +135,7 @@ module.exports = { | |
buttonNoBg: { | ||
color: 'orange', | ||
}, | ||
isSelected: { | ||
color: 'blue', | ||
}, | ||
}; |