Skip to content
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
2 changes: 2 additions & 0 deletions packages/block-library/src/playlist-track/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ const PlaylistTrackEdit = ( {
tagName="span"
className="wp-block-playlist-track__title"
value={ title }
aria-label={ __( 'Track title' ) }
placeholder={ __( 'Add title' ) }
onChange={ ( value ) => {
setAttributes( { title: value } );
Expand All @@ -281,6 +282,7 @@ const PlaylistTrackEdit = ( {
tagName="span"
className="wp-block-playlist-track__artist"
value={ artist }
aria-label={ __( 'Track artist' ) }
placeholder={ __( 'Add artist' ) }
onChange={ ( value ) =>
setAttributes( { artist: value } )
Expand Down
73 changes: 36 additions & 37 deletions packages/block-library/src/playlist-track/test/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,43 @@ import { useUploadMediaFromBlobURL } from '../../utils/hooks';

let mockMediaReplaceFlowProps;

jest.mock( '@wordpress/block-editor', () => ( {
BlockControls: ( { children } ) => <div>{ children }</div>,
BlockIcon: () => <span />,
InspectorControls: ( { children } ) => <div>{ children }</div>,
MediaPlaceholder: () => <div />,
MediaReplaceFlow: ( props ) => {
mockMediaReplaceFlowProps = props;
const { name, onSelect } = props;
return <button onClick={ () => onSelect( {} ) }>{ name }</button>;
},
MediaUpload: ( { render: renderMediaUpload } ) =>
renderMediaUpload( { open: jest.fn() } ),
MediaUploadCheck: ( { children } ) => <div>{ children }</div>,
PlainText: ( {
onChange,
placeholder,
tagName: TagName = 'div',
value,
__experimentalVersion,
...props
} ) => <TagName { ...props }>{ value || placeholder }</TagName>,
useBlockProps: jest.fn( () => ( {} ) ),
} ) );
jest.mock( '@wordpress/block-editor', () => {
const PlainText = jest.requireActual(
'../../../../block-editor/src/components/plain-text'
).default;

return {
BlockControls: ( { children } ) => <div>{ children }</div>,
BlockIcon: () => <span />,
InspectorControls: ( { children } ) => <div>{ children }</div>,
MediaPlaceholder: () => <div />,
MediaReplaceFlow: ( props ) => {
mockMediaReplaceFlowProps = props;
const { name, onSelect } = props;
return <button onClick={ () => onSelect( {} ) }>{ name }</button>;
},
MediaUpload: ( { render: renderMediaUpload } ) =>
renderMediaUpload( { open: jest.fn() } ),
MediaUploadCheck: ( { children } ) => <div>{ children }</div>,
PlainText,
useBlockProps: jest.fn( () => ( {} ) ),
};
} );

jest.mock( '@wordpress/data', () => ( {
useDispatch: jest.fn(),
combineReducers: jest.fn( ( reducers ) => ( state = {}, action ) => {
const newState = {};
Object.keys( reducers ).forEach( ( key ) => {
newState[ key ] = reducers[ key ]( state[ key ], action );
} );
return newState;
} ),
createRegistrySelector: jest.fn( ( fn ) => fn ),
createReduxStore: jest.fn( () => ( {} ) ),
createSelector: jest.fn( ( fn ) => fn ),
register: jest.fn(),
} ) );
jest.mock( '@wordpress/data', () => {
const data = jest.requireActual( '@wordpress/data' );
const mockUseDispatch = jest.fn();

return new Proxy( data, {
get( target, property ) {
if ( property === 'useDispatch' ) {
return mockUseDispatch;
}

return target[ property ];
},
} );
} );

jest.mock( '@wordpress/notices', () => ( {
store: 'core/notices',
Expand Down
Loading