Skip to content

Commit

Permalink
Tests: Ensure MediaReplaceFlow's mediaURL prop is controlled by wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsf committed Jul 4, 2022
1 parent a7a776a commit 31a0893
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,36 @@
*/
import { render, fireEvent } from '@testing-library/react';

/**
* WordPress dependencies
*/
import { useState } from '@wordpress/element';

/**
* Internal dependencies
*/
import MediaReplaceFlow from '../';

const noop = () => {};

function setUpMediaReplaceFlow() {
const { container } = render(
function TestWrapper() {
const [ mediaURL, setMediaURL ] = useState( 'https://example.media' );
return (
<MediaReplaceFlow
mediaId={ 1 }
mediaURL={ 'https://example.media' }
mediaURL={ mediaURL }
allowedTypes={ [ 'png' ] }
accept="image/*"
onSelect={ noop }
onSelectURL={ noop }
onSelectURL={ setMediaURL }
onError={ noop }
onCloseModal={ noop }
/>
);
}

function setUpMediaReplaceFlow() {
const { container } = render( <TestWrapper /> );
return container;
}

Expand Down

0 comments on commit 31a0893

Please sign in to comment.