Skip to content

Commit

Permalink
Update button block corner radius test to px (#33562)
Browse files Browse the repository at this point in the history
* Update button block corner radius test to px

* Incorporate PR feedback to make tests pass

* Remove unnecessary step from buttons test
  • Loading branch information
guarani authored Jul 26, 2021
1 parent 9d5ad61 commit 979c34a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
20 changes: 12 additions & 8 deletions packages/block-library/src/buttons/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ afterAll( () => {
describe( 'when a button is shown', () => {
it( 'adjusts the border radius', async () => {
const initialHtml = `<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"style":{"border":{"radius":"5%"}}} -->
<div class="wp-block-button"><a class="wp-block-button__link" style="border-radius:5%" >Hello</a></div>
<div class="wp-block-buttons"><!-- wp:button {"style":{"border":{"radius":"5px"}}} -->
<div class="wp-block-button"><a class="wp-block-button__link" style="border-radius:5px" >Hello</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->`;
const { getByA11yLabel, getByTestId } = await initializeEditor( {
const { getByA11yLabel } = await initializeEditor( {
initialHtml,
} );

Expand Down Expand Up @@ -66,14 +66,18 @@ describe( 'when a button is shown', () => {
);
fireEvent.press( settingsButton );

const radiusSlider = await waitFor( () =>
getByTestId( 'Slider Border Radius' )
const radiusStepper = await waitFor( () =>
getByA11yLabel( /Border Radius/ )
);
fireEvent( radiusSlider, 'valueChange', '25' );

const incrementButton = await waitFor( () =>
within( radiusStepper ).getByTestId( 'Increment' )
);
fireEvent( incrementButton, 'onPressIn' );

const expectedHtml = `<!-- wp:buttons -->
<div class="wp-block-buttons"><!-- wp:button {"style":{"border":{"radius":"25%"}}} -->
<div class="wp-block-button"><a class="wp-block-button__link" href="" style="border-radius:25%">Hello</a></div>
<div class="wp-block-buttons"><!-- wp:button {"style":{"border":{"radius":"6px"}}} -->
<div class="wp-block-button"><a class="wp-block-button__link" href="" style="border-radius:6px">Hello</a></div>
<!-- /wp:button --></div>
<!-- /wp:buttons -->`;
expect( getEditorHtml() ).toBe( expectedHtml );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function Stepper( {
) }
{ children }
<TouchableOpacity
testID={ 'Increment' }
disabled={ isMaxValue }
onPressIn={ onPressInIncrement }
onPressOut={ onPressOut }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ function Stepper( {
<Icon icon={ minus } size={ 24 } color={ buttonStyle.color } />
</TouchableOpacity>
<TouchableOpacity
testID={ 'Increment' }
disabled={ isMaxValue }
onPressIn={ onPressInIncrement }
onPressOut={ onPressOut }
Expand Down
3 changes: 3 additions & 0 deletions test/native/__mocks__/styleMock.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ module.exports = {
arrow: {
color: 'red',
},
button: {
color: 'red',
},
textInput: {
color: 'black',
},
Expand Down

0 comments on commit 979c34a

Please sign in to comment.