Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Inserter testID #18832

Merged
merged 2 commits into from
Dec 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ const defaultRenderToggle = ( { onToggle, disabled, style } ) => (
title={ __( 'Add block' ) }
icon={ ( <Dashicon icon="plus-alt" style={ style } color={ style.color } /> ) }
onClick={ onToggle }
extraProps={ { hint: __( 'Double tap to add a block' ) } }
extraProps={ {
hint: __( 'Double tap to add a block' ),
// testID is present to disambiguate this element for native UI tests. It's not
// usually required for components. See: https://git.io/JeQ7G.
testID: 'add-block-button',
} }
isDisabled={ disabled }
/>
);
Expand Down
18 changes: 18 additions & 0 deletions packages/block-editor/src/components/inserter/test/index.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/**
* External dependencies
*/
import renderer from 'react-test-renderer';

/**
* Internal dependencies
*/
import Inserter from '../index';
import '../../..'; // Ensure store dependencies are imported via root.

describe( 'Inserter', () => {
it( 'button contains the testID "add-block-button"', () => {
const component = renderer.create( <Inserter /> );
const rendered = component.toJSON();
expect( rendered.children[ 0 ].props.testID ).toEqual( 'add-block-button' );
} );
} );
2 changes: 2 additions & 0 deletions packages/components/src/button/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export function Button( props ) {
'aria-disabled': ariaDisabled,
'aria-label': ariaLabel,
'data-subscript': subscript,
testID,
} = props;

const isDisabled = ariaDisabled || disabled;
Expand Down Expand Up @@ -107,6 +108,7 @@ export function Button( props ) {
onPress={ onClick }
style={ styles.container }
disabled={ isDisabled }
testID={ testID }
>
<View style={ buttonViewStyle }>
<View style={ { flexDirection: 'row' } }>
Expand Down